Google chrome extension chrome.tabs.sendMessage:错误处理响应

Google chrome extension chrome.tabs.sendMessage:错误处理响应,google-chrome-extension,Google Chrome Extension,单击扩展图标时,我试图从background.js向content.js发送消息 Background.js: chrome.browserAction.onClicked.addListener(function(){ chrome.tabs.query({active : true, lastFocusedWindow : true}, function (tabs) { var CurrTab = tabs[0]; chrome.tabs.sendMessag

单击扩展图标时,我试图从
background.js
content.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');
   })
})
Content.js

chrome.runtime.onMessage.addListener(function(){
   view();
})
我在
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.

我做错了什么?

在Background.js中更改以下内容:

chrome.tabs.sendMessage(CurrTab, 'run');

正如wOxxOm在评论中所说的那样


其次,确保在manifest.json文件中,您已经在content_scripts/matches标记中指定了网站的url(需要插入内容脚本的地方)

当前选项卡的类型是什么?它应该是一个数字。使用
CurrTab.id
。有关更多详细信息,请参阅文档。
chrome.tabs.sendMessage(CurrTab.id, 'run');