【问题标题】:Default icon not appearing in chrome extension默认图标未出现在 chrome 扩展中
【发布时间】:2019-07-31 19:47:01
【问题描述】:

所以我做了一个 chrome 扩展,但“browser_action”下的“default_icon”对我不起作用。重新加载 chrome 扩展程序时看不到图标。有什么我可能错过的吗?

manifest.json

 {
"name": "New Extension",
"description" : "Base Level Extension",
"version": "1.0",
"manifest_version": 2,
"content_scripts" : [
    {
        "matches" : [
            "<all_urls>"
        ],
        "js" : ["content.js"]
    }
],
"background":
{
    "scripts" : [
        "background.js"
    ],

    "browser_action": {
        "default_icon": "icon.png" 
    }
}

}

我在同一个文件夹中有“icon.png”,“content.js”和“background.js”都有 2 个 console.log 语句,它们工作正常并显示出来!

【问题讨论】:

  • 将“browser_action”块移出“background”块。

标签: javascript html google-chrome google-chrome-extension


【解决方案1】:

尝试将“browser_action”块移到外面,这样它就不会嵌套在“background”块中。

 {
   "name": "New Extension",
   "description" : "Base Level Extension",
   "version": "1.0",
   "manifest_version": 2,
   "content_scripts" : [{
        "matches" : [
            "<all_urls>"
        ],
        "js" : ["content.js"]
      }
   ],
   "background": {
        "scripts" : [
          "background.js"
        ]
   },
   "browser_action": {
        "default_icon": "icon.png" 
   }
}

https://developer.chrome.com/extensions/manifest

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    相关资源
    最近更新 更多