叫我菜鸟,但我似乎无法让它工作:
var value = ""; // Tried this
function getKey(key) {
var value = ""; // And this
chrome.storage.local.get(key, function (data) {
var value = data[key];
console.log(value); // This prints the correct value
});
console.log(value); // But this will always print null
}
知道为什么吗?