aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/storagemanager/persist/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/storagemanager/persist/index.html')
-rw-r--r--files/zh-cn/web/api/storagemanager/persist/index.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/storagemanager/persist/index.html b/files/zh-cn/web/api/storagemanager/persist/index.html
new file mode 100644
index 0000000000..2f778b9832
--- /dev/null
+++ b/files/zh-cn/web/api/storagemanager/persist/index.html
@@ -0,0 +1,53 @@
+---
+title: StorageManager.persist()
+slug: Web/API/StorageManager/persist
+translation_of: Web/API/StorageManager/persist
+---
+<p>{{securecontext_header}}{{APIRef("Storage")}}{{SeeCompatTable}}</p>
+
+<p><span class="seoSummary"><strong><code>persist()</code></strong></span>方法是<span class="seoSummary">{{domxref("StorageManager")}}的一个接口,用于请求本地数据存储的权限,如果被授予权限,则返回一个resolved状态值为<code>true</code>的{{jsxref('Promise')}}对象,否则返回<code>false</code>。</span></p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">navigator.storage.persist().then(function(persistent) { ... })</pre>
+
+<h3 id="参数">参数</h3>
+
+<p>无</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个resolved状态,值为{{jsxref('Boolean')}}类型的{{jsxref('Promise')}}对象。</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">if (navigator.storage &amp;&amp; navigator.storage.persist)
+  navigator.storage.persist().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.");
+  });</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Storage','#dom-storagemanager-persist','persist')}}</td>
+ <td>{{Spec2('Storage')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.StorageManager.persist")}}</p>