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