ServiceWorkerRegistration: index 属性
注意:此功能在 Web Workers 中可用。
ServiceWorkerRegistration 接口中只读的 index 属性返回一个指向 ContentIndex 接口的引用,该接口允许索引离线内容。
值
一个 ContentIndex 对象。
示例
您可以从主脚本或已注册的服务工作者访问该属性。
这是主脚本中的一个示例
js
// reference registration
const registration = await navigator.serviceWorker.ready;
// feature detection
if ("index" in registration) {
// Content Index API functionality
const contentIndex = registration.index;
}
来自 服务工作者
js
// service worker script
const contentIndex = self.registration.index;
规范
| 规范 |
|---|
| Content Index # dom-serviceworkerregistration-index |
浏览器兼容性
加载中…