我有一个扩展,它需要来自本地存储的一些数据。算法:如果数据未找到(或为空)则 alert(); 并返回;
var storage = chrome.storage.local;
storage.get('data', function(items)
{
if (!items.data.apiKey) { alert('Api key not set!'); return;} // not working
//nextstuff that is not working if there is no items.data.apiKey
}
此代码在 Windows 上运行良好。在 Mac OS 中它不会提醒我,如果它不返回数据,它会返回。