From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- .../webextensions/api/storage/local/index.html | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 files/zh-tw/mozilla/add-ons/webextensions/api/storage/local/index.html (limited to 'files/zh-tw/mozilla/add-ons/webextensions/api/storage/local') diff --git a/files/zh-tw/mozilla/add-ons/webextensions/api/storage/local/index.html b/files/zh-tw/mozilla/add-ons/webextensions/api/storage/local/index.html new file mode 100644 index 0000000000..3cdc3ab140 --- /dev/null +++ b/files/zh-tw/mozilla/add-ons/webextensions/api/storage/local/index.html @@ -0,0 +1,84 @@ +--- +title: storage.local +slug: Mozilla/Add-ons/WebExtensions/API/storage/local +translation_of: Mozilla/Add-ons/WebExtensions/API/storage/local +--- +
{{AddonSidebar()}}
+ +

代表 local 儲存空間。通常 local 裡面的東西,會放在套件安裝的地方。

+ +

瀏覽器可能會限制套件本地可儲存的資料數量:

+ + + +

如果套件被移除、相關的儲存資料也會一併移除。

+ +

在 Firefox 內,你可以透過 about:config 內設定 keepUuidOnUninstall 與 keepStorageOnUninstall 為 true 以避免瀏覽器在移除套件時,一併移除相關的儲存資料。這個功能是為了方便開發者除錯,套件本身無法改變這個設定。

+ +

雖然這 API 與 {{domxref("Window.localStorage")}} 相似,但不建議在套件內使用 Window.localStorage。在某些情況下,用戶會出於隱私上的理由,要求 Firefox 清理瀏覽紀錄與資料,這其中就包含使用 localStorage API 的資料。另一方面,storage.local API 的資料,在這種情況下會予以保留。

+ +

方法

+ +

local 物件實做了定義於 {{WebExtAPIRef("storage.StorageArea")}} 類別的方法:

+ +
+
{{WebExtAPIRef("storage.StorageArea.get()")}}
+
取得一個或多個源自儲存空間的項目。
+
{{WebExtAPIRef("storage.StorageArea.getBytesInUse()")}}
+
取得儲存空間內,一個或多個已為項目所使用的容量。單位為 byte。
+
{{WebExtAPIRef("storage.StorageArea.set()")}}
+
Stores one or more items in the storage area. If the item already exists, its value will be updated. When you set a value, the {{WebExtAPIRef("storage.onChanged")}} event will fire.
+
{{WebExtAPIRef("storage.StorageArea.remove()")}}
+
刪除一個或多個儲存空間內的項目。
+
{{WebExtAPIRef("storage.StorageArea.clear()")}}
+
刪除所有儲存空間內的項目。
+
+ +

瀏覽器相容性

+ + + +

{{Compat("webextensions.api.storage.local")}}

+ +

{{WebExtExamples}}

+ +
致謝 + +

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + -- cgit v1.2.3-54-g00ecf