Chrome扩展程序中未显示默认图标

时间:2019-03-10 08:35:21

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

所以我做了一个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语句,它们运行良好并显示出来! < / p>

1 个答案:

答案 0 :(得分:0)

请尝试将“ 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