这篇翻译不完整。请帮忙从英语翻译这篇文章

 Request 接口中的clone() 方法可以创建一个当前Request 对象的副本。

 如果响应体Body已经被使用过,那么clone()会抛出一个TypeError。实际上,clone() 的主要作用就是支持Body对象的多次使用

语法

var newRequest = request.clone();

参数

无。

返回值

Request对象,也就是Request的完整拷贝

示例

在下面的代码中,我们使用Request.Request()构造函数创建了一个新的request对象(请求当前文件夹中的一个图片文件),然后拷贝了这个request对象。

var myRequest = new Request('flowers.jpg');
var newRequest = myRequest.clone(); // a copy of the request is now stored in newRequest

规范

规范 状态 说明
Fetch
clone
Living Standard 初始化定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
clone
Experimental
Chrome Full support 42
Full support 42
Full support 41
Disabled
Disabled From version 41: this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge Full support 14Firefox Full support 39
Full support 39
Full support 34
Disabled
Disabled From version 34: this feature is behind the dom.fetch.enabled preference. To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 29
Full support 29
Full support 28
Disabled
Disabled From version 28: this feature is behind the Experimental Web Platform Features preference.
Safari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android Full support 29
Full support 29
Full support 28
Disabled
Disabled From version 28: this feature is behind the Experimental Web Platform Features preference.
Safari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.
User must explicitly enable this feature.

了解更多

文档标签和贡献者

此页面的贡献者: sixpencecl
最后编辑者: sixpencecl,