错误处理响应:TypeError:无法读取未定义的属性“ setPopup”

问题描述

最终目标是检查标签url,如果匹配则在徽章中显示消息或警报,但是在chrome.browserAction中变得不确定,而在我的background.js中则是偶数。浏览了几篇文章,但无法解决该错误。

  1. Why is chrome.browserAction.onClicked undefined (in the background script)?
  2. Why is chrome.browserAction.onClicked undefined?

background.js

chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab) {
  chrome.browserAction.setPopup({"tabId":tabId,"popup": "popup.html"});
});

Manifest.json

{
  "name": "","version": "1.0","description": "Extension for","permissions": ["tabs","activeTab","declarativeContent","storage","identity","identity.email"],"options_page": "options.html","background": {
    "scripts": ["background.js"],"persistent": false,"browser_action": {
      "default_popup": "popup.html"
    }
  },"page_action": {
    "default_popup": "popup.html","default_icon": {
      "16": "images/get_started16.png","32": "images/get_started32.png","48": "images/get_started48.png","128": "images/get_started128.png"
    }
  },"icons": {
    "16": "images/get_started16.png","128": "images/get_started128.png"
  },"manifest_version": 2,"content_scripts": [{
    "matches": ["<all_urls>"],"js": ["popup.js"]
    }]
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)