【问题标题】:chrome.storage.local.get failing within chrome.storage.sync.get callbackchrome.storage.local.get 在 chrome.storage.sync.get 回调中失败
【发布时间】:2020-06-04 13:13:10
【问题描述】:

它刚刚工作,现在我无法进入 chrome.storage.local.get() 的回调。

我在本地存储中有数据并且我已经正确写入了。

为什么会失败?是我误解了什么还是我错过了什么?

chrome.storage.sync.get("wortlisteOptionId", function(result){
    if(result["wortlisteOptionId"] != "" && result["wortlisteOptionId"] !== undefined){
        var prevSelection = result["wortlisteOptionId"];
    }
    var item = document.getElementById('wortlisten');
    // works till here
    chrome.storage.local.get("wortlisten", function(result)
    {
        let val;
        let optioncollection = "";
        if(result["wortlisten"] != null){
            for(val of result["wortlisten"]){
                optioncollection += '<option value="' + val.id + '">' + val.name + '</option>';                
            }
            item.innerHTML = optioncollection;

            if(prevSelection != null){
                item.selectedIndex = prevSelection;
            }
            restoreLocalData();                
        }
    });
});

【问题讨论】:

    标签: javascript google-chrome chrome-plugins


    【解决方案1】:

    我不确定是什么导致了这个问题。我最好的猜测是,我在本地机器上使用 xampp 对其进行了测试,但性能非常糟糕。在我用我的生产环境测试它之后,我没有遇到这个问题......

    在路上我还发现了这个页面,上面有一些解释:Returning Chrome storage API value without function

    【讨论】:

      猜你喜欢
      • 2018-07-29
      • 2013-01-13
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多