我试图在单击扩展图标时向content.jsfrom发送消息。background.js
Background.js:
chrome.browserAction.onClicked.addListener(function(){
chrome.tabs.query({active : true, lastFocusedWindow : true}, function (tabs) {
var CurrTab = tabs[0];
chrome.tabs.sendMessage(CurrTab, 'run');
})
})
Run Code Online (Sandbox Code Playgroud)
Content.js:
chrome.runtime.onMessage.addListener(function(){
view();
})
Run Code Online (Sandbox Code Playgroud)
我有这个错误background.js,我不知道为什么。
Error handling response: TypeError: Error in invocation of
tabs.sendMessage(integer tabId, any message, optional object options,
optional function responseCallback): No matching signature.
Run Code Online (Sandbox Code Playgroud)
我做错了什么?