我正在使用 AngularJS 制作一个 Chrome 打包应用程序,我只是试图从我的后台脚本(“runtime.js”)发送一条消息到我项目中的另一个 javascript 文件。
清单.json
{
"name": "App Name",
"description": "Chrome Packaged",
"version": "0.0.9",
"manifest_version": 2,
"icons": {
"16": "img/icon16.png",
"48": "img/icon48.png",
"128":"img/icon128.png"
},
"app": {
"background": {
"scripts": ["runtime.js"]
}
},
"permissions": [
"alarms",
"storage",
"unlimitedStorage",
"notifications",
"app.runtime"
]
}
运行时.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
minWidth: 400,
minHeight: 700,
bounds: {
width: 1000,
height: 700
}
});
});
chrome.runtime.sendMessage({message: "hello"}, function() {
console.log('sent')
});
main.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log('message received!');
});
我检查后台页面时不断收到的错误是“端口:无法建立连接。接收端不存在。”
关于可能是什么问题的任何想法?谢谢!