From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/storagemanager/persisted/index.html | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 files/zh-cn/web/api/storagemanager/persisted/index.html (limited to 'files/zh-cn/web/api/storagemanager/persisted') diff --git a/files/zh-cn/web/api/storagemanager/persisted/index.html b/files/zh-cn/web/api/storagemanager/persisted/index.html new file mode 100644 index 0000000000..0e3c7c4711 --- /dev/null +++ b/files/zh-cn/web/api/storagemanager/persisted/index.html @@ -0,0 +1,53 @@ +--- +title: StorageManager.persisted() +slug: Web/API/StorageManager/persisted +translation_of: Web/API/StorageManager/persisted +--- +

{{securecontext_header}}{{APIRef("Storage")}}{{SeeCompatTable}}

+ +

persisted()方法是{{domxref("StorageManager")}}的一个接口,如果盒存储模式(box mode)的值为 “persistent” 则返回一个resolved状态值为true的{{jsxref('Promise')}}。

+ +

语法

+ +
navigator.storage.persisted().then(function(persistent) { ... })
+ +

参数

+ +

+ +

返回值

+ +

一个状态为resolved,值为{{jsxref('Boolean')}}类型的{{jsxref('Promise')}}。

+ +

示例

+ +
if (navigator.storage && navigator.storage.persist)
+  navigator.storage.persisted().then(function(persistent) {
+    if (persistent)
+      console.log("Storage will not be cleared except by explicit user action");
+    else
+      console.log("Storage may be cleared by the UA under storage pressure.");
+  });
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Storage','#dom-storagemanager-persisted','persisted')}}{{Spec2('Storage')}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("api.StorageManager.persisted")}}

-- cgit v1.2.3-54-g00ecf