我剛剛開始使用Chrome擴展程序。Chrome擴展程序 - 結果始終爲空
在我content.js我有以下
chrome.runtime.sendMessage("", function(response){
//some logic
});
而且在background.js
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
sendResponse(someFunction);
return true;
});
function someFunction(para) {
//logic
}
的問題是,在content.js的response
永遠是不確定的......類似的帖子在這個網站上通常是由於異步調用,如ajax,但我沒有做任何異步,我回到了真正的根據文檔返回的方法...我只能假設我的邏輯是一些倒退?
我做錯了什麼?
刪除括號 - 它只是:'AddToBody parent'。或者像這樣使用'Call':'Call AddToBody(parent)' – Rory