aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/storagemanager/persisted/index.html
blob: 0e3c7c471160fb51c77cd869abe44a6d2b7c7c30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
title: StorageManager.persisted()
slug: Web/API/StorageManager/persisted
translation_of: Web/API/StorageManager/persisted
---
<p>{{securecontext_header}}{{APIRef("Storage")}}{{SeeCompatTable}}</p>

<p><span class="seoSummary"><strong><code>persisted()</code></strong></span>方法是<span class="seoSummary">{{domxref("StorageManager")}}的一个接口,如果盒存储模式(</span><strong>box mode</strong><span class="seoSummary">)的值为 “<strong>persistent</strong>” 则返回一个resolved状态值为<code>true</code>{{jsxref('Promise')}}</span></p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">navigator.storage.persisted().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"><code>if (navigator.storage &amp;&amp; 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.");
  });</code></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-persisted','persisted')}}</td>
   <td>{{Spec2('Storage')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.StorageManager.persisted")}}</p>