URL:revokeObjectURL() 静态方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

备注: 此特性在 Web Worker(不包括 Service Worker)中可用。

URL 接口的 revokeObjectURL() 静态方法用于释放之前通过调用 URL.createObjectURL() 创建的现有对象 URL。

当你完成对对象 URL 的使用后,请调用此方法,让浏览器知道无需再保持对文件的引用。

备注: 由于 Blob 接口的生命周期问题及潜在的内存泄漏风险,此方法在 Service Worker可用。

语法

js
URL.revokeObjectURL(objectURL)

参数

objectURL

表示之前通过调用 createObjectURL() 方法创建的对象 URL 的字符串。

返回值

无(undefined)。

示例

规范

Specification
File API
# dfn-revokeObjectURL

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
revokeObjectURL() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见