【发布时间】:2012-09-20 15:17:40
【问题描述】:
我在 http://developer.chrome.com/trunk/apps/first_app.html 上关注 google chrome 网络应用程序开发,但网络应用程序没有启动。当我单击页面上的应用程序图标时,它会关闭选项卡。我已经从 github 下载了示例应用程序和插件,但是当我查看控制台时它们也无法正常工作,我收到此错误,请不要我在 chrome://flags 中启用了实验性 API。
Uncaught TypeError: Cannot read property 'onLaunched' of undefined
我已将我的 chrome 浏览器更新到版本 22.0.1229.79。我的 manifest.json 文件是
{
"name": "Hello World!",
"description": "My first packaged app.",
"manifest_version": 2,
"version": "0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "calculator-16.png",
"128": "calculator-128.png"
}
}
还有我的 background.js 文件
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'width': 400,
'height': 500
});
});
谁能指出我哪里出错了?
【问题讨论】:
-
我有一个类似的问题 (see here),在我重新启动浏览器后似乎已经解决了。我一直在运行许多选项卡,并且浏览器已经打开了一段时间。
-
我最终将清单更改为如下所示
{ "name": "Qlipe", "description": "Qlipe Chrome app", "manifest_version": 2, "version": "0.1", "app": { "launch": { "local_path": "index.html" } }, "icons": { "16": "Qlipe-16.png", "128": "Qlipe-128.png" }, "permissions": [ "http://www.qlipe.com/api/feed", "http://0.0.0.0:6543/api/feed", "unlimitedStorage" ]注意我删除了背景 js -
有趣。当我有机会时,我会玩它。您是否尝试过指定 background.html 并将 javascript 嵌入其中?
标签: google-chrome google-chrome-extension google-chrome-app