</code></pre></div></li><li><p><strong>详情:</strong></p><p>自定义读取缓存</p></li><li><p><strong>参考:</strong> <a href="/guide/documentation/cacheKey.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BC%93%E5%AD%98" class="">自定义缓存</a></p></li></ul><h3 id="errorretrycount" tabindex="-1"><a class="header-anchor" href="#errorretrycount" aria-hidden="true">#</a> errorRetryCount <span class="badge tip" style="vertical-align:top;"><!--[-->响应式<!--]--></span></h3><ul><li><p><strong>类型:</strong> <code>number | Ref<number></code></p></li><li><p><strong>默认值:</strong> <code>0</code></p></li><li><p><strong>详情:</strong></p><p>最大错误重试次数</p></li><li><p><strong>参考:</strong> <a href="/guide/documentation/errorRetry.html#%E9%87%8D%E8%AF%95%E6%AC%A1%E6%95%B0" class="">错误重试次数</a></p></li></ul><h3 id="errorretryinterval" tabindex="-1"><a class="header-anchor" href="#errorretryinterval" aria-hidden="true">#</a> errorRetryInterval <span class="badge tip" style="vertical-align:top;"><!--[-->响应式<!--]--></span></h3><ul><li><p><strong>类型:</strong> <code>number | Ref<number></code></p></li><li><p><strong>默认值:</strong> <code>0</code></p></li><li><p><strong>详情:</strong></p><p>默认情况下,VueRequest 使用<a href="https://en.wikipedia.org/wiki/Exponential_backoff" target="_blank" rel="noopener noreferrer"><strong>二进制指数退避算法</strong><span><svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" ariaHidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><!--[--><span class="sr-only">在新窗口打开</span><!--]--></span></a> 来帮你计算出合适的间隔时间,你也可以通过设置 <code>errorRetryInterval</code> 来覆盖默认行为</p></li><li><p><strong>参考:</strong> <a href="/guide/documentation/errorRetry.html#%E9%87%8D%E8%AF%95%E9%97%B4%E9%9A%94%E6%97%B6%E9%97%B4" class="">错误重试间隔时间</a></p></li></ul><h3 id="manual" tabindex="-1"><a class="header-anchor" href="#manual" aria-hidden="true">#</a> manual</h3><ul><li><p><strong>类型:</strong> <code>boolean</code></p></li><li><p><strong>默认值:</strong> <code>false</code></p></li><li><p><strong>详情:</strong></p><p>当 <code>manual</code> 设置为 <code>true</code> 时,你需要手动触发 <a href="#run"><code>run</code></a> 或者 <a href="#runAsync"><code>runAsync</code></a> 才会发起请求</p></li><li><p><strong>参考:</strong> <a href="/guide/documentation/manual.html" class="">手动请求</a></p></li></ul><h3 id="defaultparams" tabindex="-1"><a class="header-anchor" href="#defaultparams" aria-hidden="true">#</a> defaultParams</h3><ul><li><p><strong>类型:</strong> <code>P[]</code></p></li><li><p><strong>默认值:</strong> <code>[]</code></p></li><li><p><strong>详情:</strong></p><p>如果 <a href="#manual"><code>manual</code></a> 设置为 <code>false</code> ,在自动执行请求的时候,将会把 <code>defaultParams</code> 作为请求参数</p></li></ul><h3 id="ready" tabindex="-1"><a class="header-anchor" href="#ready" aria-hidden="true">#</a> ready <span class="badge tip" style="vertical-align:top;"><!--[-->响应式<!--]--></span></h3><ul><li><p><strong>类型:</strong> <code>Ref<boolean> | () => boolean</code></p></li><li><p><strong>默认值:</strong> <code>true</code></p></li><li><p><strong>详情:</strong></p><p>只有当 <code>ready</code> 为 <code>true</code> 时,才会发起请求。</p><ul><li>自动模式:当 <code>manual=false</code> 时,每次 <code>ready</code> 从 <code>false</code> 变为 <code>true</code> 时,都会自动发起请求,并且会带上参数 <code>options.defaultParams</code>。</li><li>手动模式:当 <code>manual=true</code> 时,只要 <code>ready</code> 为 <code>false</code>,则无法发起请求。</li></ul></li><li><p><strong>参考:</strong> <a href="/guide/documentation/ready.html" class="">依赖请求</a></p></li></ul><h3 id="initialdata" tabindex="-1"><a class="header-anchor" href="#initialdata" aria-hidden="true">#</a> initialData</h3><ul><li><p><strong>类型:</strong> <code>R</code></p></li><li><p><strong>默认值:</strong> <code>undefined</code></p></li><li><p><strong>详情:</strong></p><p>默认的 <a href="#data"><code>data</code></a></p></li></ul><h3 id="refreshdeps" tabindex="-1"><a class="header-anchor" href="#refreshdeps" aria-hidden="true">#</a> refreshDeps</h3><ul><li><p><strong>类型:</strong> <code>WatchSource<any> | WatchSource<any>[]</code></p></li><li><p><strong>默认值:</strong> <code>[]</code></p></li><li><p><strong>详情:</strong></p><p>当 <code>refreshDeps</code> 里面的内容发生变化时,如果没有设置 <a href="#refreshdepsaction"><code>refreshDepsAction</code></a>, 就会触发 <code>refresh</code> 的重新执行。其本质只是对 <a href="https://v3.vuejs.org/guide/computed.html#watchers" target="_blank" rel="noopener noreferrer"><code>watch</code><span><svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" ariaHidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><!--[--><span class="sr-only">在新窗口打开</span><!--]--></span></a> 的封装。</p><div class="language-javascript ext-js"><pre class="language-javascript"><code><span class="token function">watch</span><span class="token punctuation">(</span>refreshDeps<span class="token punctuation">,</span> refresh<span class="token punctuation">)</span><span class="token punctuation">;</span>
0 commit comments