0
我有回调此函数:错误与异步js函数和记录
function getStorageByKey(key, callback) {
chrome.storage.sync.get(key, function(obj, callback) {
var error = chrome.runtime.lastError;
if (error) {
console.error(error);
}
callback(obj)
});
}
我试图登录是这样的输出:
getStorageByKey('hidden_threads', function (data) {
console.log(data);
});
我收到以下错误:
Error in response to storage.get: TypeError: callback is not a function
at Object.callback (chrome-extension://nnaebcfbeghbbdkcgdicmlagdblheccm/content.js:37:3)
at getStorageByKey (chrome-extension://nnaebcfbeghbbdkcgdicmlagdblheccm/content.js:32:23)
at HTMLDocument.<anonymous> (chrome-extension://nnaebcfbeghbbdkcgdicmlagdblheccm/content.js:8:3)
at j (chrome-extension://nnaebcfbeghbbdkcgdicmlagdblheccm/jquery.min.js:2:29999)
at k (chrome-extension://nnaebcfbeghbbdkcgdicmlagdblheccm/jquery.min.js:2:30313)
@Vasan这工作!如果你想把它写成答案,我会接受它。 – metersk
完成了,我已经成为一个答案! :-) – Vasan