草案
此页面不完整。

delete() 方法在 ContentIndex interface unregisters an item from the currently indexed content.

调用 delete() only affects the index. It does not delete anything from the 缓存 .

句法

ContentIndex.delete(id).then(...);
					

参数

This method receives no parameters.

返回值

返回 Promise that resolves with undefined

异常

No exceptions are thrown.

范例

Below is an asynchronous function, that removes an item from the content index . We receive a reference to the current ServiceWorkerRegistration , which allows us to access the index property and thus access the delete 方法。

async function unregisterContent(article) {
  // reference registration
  const registration = await navigator.serviceWorker.ready;
  // feature detect Content Index
  if (!registration.index)
    return;
  // unregister content from index
  await registration.index.delete(article.id);
}
					

delete method can also be used within the service worker scope.

self.registration.index.delete('my-id');
					

规范

规范 状态 注释
未知
The definition of 'delete' in that specification.
未知 初始定义。

浏览器兼容性

The compatibility table in 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.

No compatibility data found. Please contribute data for "api.ContentIndex.delete" (depth: 1) to the MDN 兼容性数据存储库 .

另请参阅:

元数据

  • 最后修改: