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 |
瀏覽器相容性
載入中…