SharedStorageWorkletGlobalScope
SharedStorageWorkletGlobalScope 介面是 Shared Storage API 的一部分,代表 SharedStorageWorklet 模組的全域性作用域。
例項屬性
-
包含一個
WorkletSharedStorage物件的例項,該物件在 worklet 上下文中表示特定源的共享儲存。
例項方法
register()實驗性-
註冊在當前 worklet 模組中定義的操作。
示例
js
// ab-testing-worklet.js
class SelectURLOperation {
async run(urls, data) {
// Read the user's experiment group from shared storage
const experimentGroup = await this.sharedStorage.get("ab-testing-group");
// Return the group number
return experimentGroup;
}
}
register("ab-testing", SelectURLOperation);
有關此示例的詳細介紹以及其他示例的連結,請參閱 共享儲存 API 登入頁。
規範
| 規範 |
|---|
| 共享儲存 API # sharedstorageworkletglobalscope |
瀏覽器相容性
載入中…