StorageManager.persist()
**persist()
**方法是StorageManager
的一个接口,用于请求本地数据存储的权限,如果被授予权限,则返回一个 resolved 状态值为true
的Promise
对象,否则返回false
。
语法
navigator.storage.persist().then(function(persistent) { ... })
参数
无
返回值
示例
js
if (navigator.storage && 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.");
});
规范
Specification |
---|
Storage Standard # ref-for-dom-storagemanager-persist |
浏览器兼容性
BCD tables only load in the browser