chrome.storage.local.get 在 chrome.storage.sync.get 回调中失败
chrome.storage.local.get failing within chrome.storage.sync.get callback
它刚刚工作,现在我无法进入 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();
}
});
});
我不确定是什么导致了这个问题。我最好的猜测是,我在我的本地机器上用 xampp 测试了它,性能很糟糕。在我的生产环境中对其进行测试后,我没有遇到这个问题....
在路上我还发现了这个页面,其中有一些解释:Returning Chrome storage API value without function
它刚刚工作,现在我无法进入 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();
}
});
});
我不确定是什么导致了这个问题。我最好的猜测是,我在我的本地机器上用 xampp 测试了它,性能很糟糕。在我的生产环境中对其进行测试后,我没有遇到这个问题....
在路上我还发现了这个页面,其中有一些解释:Returning Chrome storage API value without function