如何删除 chrome.storage.local

马亨德拉

我不知道如何chrome.storage.local在 javascript 中删除值?

我是这样使用的,但存储值没有从商店中删除:chrome.storage.local.remove(result.MyFile.Base64File);

请检查下面的代码,这里我使用chrome.storage.local.set来设置

var obj = { DocName: "name", Base64File: "Base64string" };
                chrome.storage.local.set({ 'MyFile': obj });

和 chrome.storage.local.get 检索值

   chrome.storage.local.get('MyFile', function (result) {
  var PdfBase64 = result.MyFile.Base64File;
   var DocumentName = result.MyFile.DocName;
}
用户9453460

注意:您不能删除值,您可以删除具有特定名称的索引,是什么原因导致它们被删除的值。

Tbh 我无法运行代码,但我很确定这样的事情应该可以工作。但我真的建议你避免使用 chrome.storage 因为它是某种“愚蠢的”:)

所以请看一下这段代码:

function clearItem(symbol) {
  var remove = [];

  chrome.storage.sync.get(function(Items) {
    $.each(Items, function(index, value) {
      if (index == "symbol") remove.push(index);
    });

    chrome.storage.sync.remove(remove, function(Items) {
      chrome.storage.sync.get(function(Items) {
        $.each(Items, function(index, value) {
          console.log("removed: " + index);
        });
      });
    });
  });
};

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何否定 chrome.storage.local 中的变量

开发Chrome扩展程序时如何清除“ chrome.storage.local”缓存?

从JavaScript中的chrome.storage.local中删除以字符串开头的变量

chrome.storage.local 写入密钥的问题

chrome.storage.local.get和set

window.localStorage与chrome.storage.local

Chrome.Storage.Local持久性

从chrome.storage.local获取原始值

使用chrome.storage.local.set存储数据的安全性如何

如何使用chrome.storage.local.get和XMLHttpRequest同步执行功能?

chrome.storage.local get返回“未定义”

为什么 chrome.storage.local.get 返回 undefined 的值?

用玩笑测试chrome.storage.local.set

无法使用chrome.storage.local.set保存集

使用 chrome.storage.local.set 时 JSON 对象损坏

chrome.storage.local。在chrome.runtime.reload()之后获取空-打包的应用

chrome扩展名:从本地存储切换到chrome.storage.local

Chrome 擴展開發:chrome.storage.local vs Indexeddb

如何自动清除chrome.storage

如何解决chrome.storage.sync?

如何使用chrome.storage扩展

如何从chrome.storage检索此值?

如何使用 chrome.storage.sync.remove 从数组中删除一项?

chrome ... addListener,如何等待chrome.storage.sync.get?

从 chrome.storage.sync 中删除数据?

chrome.storage.local.get 在浏览器启动期间返回 undefined,但仅针对特定值

是否可以在开发人员工具中查看chrome.storage.local?

为什么chrome.storage.local仅保存最后一条记录?

在包含chrome.storage.local中保存的对象数组的对象中检查密钥