SharedStorageWorkletGlobalScope: thuộc tính sharedStorage

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Thuộc tính chỉ đọc context của giao diện SharedStorageWorkletGlobalScope chứa một thể hiện đối tượng WorkletSharedStorage, đại diện cho bộ lưu trữ dùng chung cho một nguồn gốc cụ thể như được hiển thị trong ngữ cảnh worklet.

Giá trị

Một thể hiện đối tượng WorkletSharedStorage.

Ví dụ

js
// ab-testing-worklet.js
class SelectURLOperation {
  async run(urls, data) {
    // Đọc nhóm thử nghiệm của người dùng từ shared storage
    const experimentGroup = await this.sharedStorage.get("ab-testing-group");

    // Trả về số nhóm
    return experimentGroup;
  }
}

register("ab-testing", SelectURLOperation);

Thông số kỹ thuật

Thông số kỹ thuật
Shared Storage API
# dom-sharedstorageworkletglobalscope-sharedstorage

Tương thích trình duyệt

Xem thêm