diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/request/clone | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/request/clone')
-rw-r--r-- | files/zh-cn/web/api/request/clone/index.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/request/clone/index.html b/files/zh-cn/web/api/request/clone/index.html new file mode 100644 index 0000000000..a256435381 --- /dev/null +++ b/files/zh-cn/web/api/request/clone/index.html @@ -0,0 +1,62 @@ +--- +title: Request.clone() +slug: Web/API/Request/clone +translation_of: Web/API/Request/clone +--- +<div>{{APIRef("Fetch")}}</div> + +<div></div> + +<p> {{domxref("Request")}} 接口中的<strong><code>clone()</code></strong> 方法可以创建一个当前<code>Request</code> 对象的副本。</p> + +<p> 如果响应体{{domxref("Body")}}已经被使用过,那么<code>clone()会抛出一个</code>{{jsxref("TypeError")}}。实际上,<code>clone()</code> 的主要作用就是支持{{domxref("Body")}}对象的多次使用</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: js">var newRequest = request.clone();</pre> + +<h3 id="参数">参数</h3> + +<p>无。</p> + +<h3 id="返回值">返回值</h3> + +<p>{{domxref("Request")}}对象,也就是<code>Request的完整拷贝</code></p> + +<h2 id="示例">示例</h2> + +<p>在下面的代码中,我们使用<code>{{domxref("Request.Request()")}}构造函数创建了一个新的request对象(请求当前文件夹中的一个图片文件),然后拷贝了这个request对象。</code></p> + +<pre class="brush: js">var myRequest = new Request('flowers.jpg'); +var newRequest = myRequest.clone(); // a copy of the request is now stored in newRequest</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">说明</th> + </tr> + <tr> + <td>{{SpecName('Fetch','#dom-request-clone','clone')}}</td> + <td>{{Spec2('Fetch')}}</td> + <td>初始化定义</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.Request.clone")}}</p> + +<h2 id="了解更多">了解更多</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/ServiceWorker_API">ServiceWorker API</a></li> + <li><a href="/en-US/docs/Web/HTTP/Access_control_CORS">HTTP access control (CORS)</a></li> + <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li> +</ul> |