chrome.runtime.onInstalled 是否在加载解压扩展时触发?
Does chrome.runtime.onInstalled fire when loading unpacked extensions?
我正在测试我的 chrome 插件并尝试测试 chrome.runtime.onInstalled
。
我的代码如下
function installed(){
alert("Success");
}
chrome.runtime.onInstalled.addListener(installed);
但是当通过 loading unpacked extension
加载扩展时。我根本没有收到任何警报。 `chrome.runtime.onInstalled 好像没火。我该如何测试?
以上代码位于 popup.js
中,并在来自 popup.html
的脚本标记中调用。该部分的 manifest.json
文件如下所示。
"browser_action": {
"default_icon": {
"19": "images/enabled-icon-19.png"
//"38": "images/icon38.png"
},
"default_popup": "popup.html",
"default_title": "mytitle"
}
对于 chrome.runtime.onInstalled
到 运行,您需要编辑 manifest.json
文件并添加
"background": {
"scripts": ["background.js"]
}
将 chrome.runtime.onInstalled.addListener(installed);
行连同所有必需的函数放在那里。然后它将按预期工作。
我正在测试我的 chrome 插件并尝试测试 chrome.runtime.onInstalled
。
我的代码如下
function installed(){
alert("Success");
}
chrome.runtime.onInstalled.addListener(installed);
但是当通过 loading unpacked extension
加载扩展时。我根本没有收到任何警报。 `chrome.runtime.onInstalled 好像没火。我该如何测试?
以上代码位于 popup.js
中,并在来自 popup.html
的脚本标记中调用。该部分的 manifest.json
文件如下所示。
"browser_action": {
"default_icon": {
"19": "images/enabled-icon-19.png"
//"38": "images/icon38.png"
},
"default_popup": "popup.html",
"default_title": "mytitle"
}
对于 chrome.runtime.onInstalled
到 运行,您需要编辑 manifest.json
文件并添加
"background": {
"scripts": ["background.js"]
}
将 chrome.runtime.onInstalled.addListener(installed);
行连同所有必需的函数放在那里。然后它将按预期工作。