error() 方法在 响应 interface returns a new 响应 object associated with a network error.

注意 : This is mainly relevant to ServiceWorkers ; the error method is used to return an error if you so wish it. An error response has its type 设为 error .

注意 : An "error" 响应 never really gets exposed to script: such a response to a fetch() would reject the promise.

句法

var errorResponse = Response.error();
					

参数

None.

返回值

A 响应 对象。

范例

TBD (does not yet appear to be supported anywhere).

规范

规范 状态 注释
Fetch
The definition of 'error()' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
error Chrome Yes Edge 16 Firefox Yes IE No Opera Yes Safari Yes WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: