[英]Cordova: Device Ready doesn't show
I made a cordova project and device ready worked, I didn't get any errors. 我做了一个cordova项目,设备准备就绪,没有出现任何错误。 Then I tried to add two javascript files and a folder full of images.
然后,我尝试添加两个javascript文件和一个充满图像的文件夹。 I have linked them in the index.html and didn't delete anything.. Now Device Ready does fire?
我已将它们链接到index.html中,但未删除任何内容。 Note: I am using Xcode and developing a game for iOS and Android.
注意:我正在使用Xcode并为iOS和Android开发游戏。
Here is the HTML: 这是HTML:
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Badger Hop</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="phaser.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
One Javascript file can be found here: http://pastebin.com/QmpCUSA5 (main.js). 可以在这里找到一个Javascript文件: http ://pastebin.com/QmpCUSA5(main.js)。 The other file is Phaser.Min.js (found here: https://github.com/photonstorm/phaser/blob/master/build/phaser.min.js )
另一个文件是Phaser.Min.js(在此处找到: https : //github.com/photonstorm/phaser/blob/master/build/phaser.min.js )
In your main.js
file I can't find any deviceready
event handler. 在您的
main.js
文件中,我找不到任何设备deviceready
事件处理程序。
Your app should wait this event before using any cordova function. 您的应用应先等待此事件,然后再使用任何cordova函数。 You should wrap your app initializing function with a code like this:
您应该使用以下代码包装应用程序初始化函数:
document.addEventListener('deviceready', function () {
console.log("Start App");
// call your app init function
}
For a more clear example see the Cordova hello world app . 有关更清晰的示例,请参见Cordova hello world应用程序 。
Does your js/index.js
contains this code? 您的
js/index.js
是否包含此代码? Check it. 核实。
Solved it.. I renamed the project after I put all those files in, turns out you can't do this. 解决了..将所有这些文件放入后,我将项目重命名,结果您无法执行此操作。 I changed the name back to what it was before and now it works!
我将名称改回原来的名称,现在可以使用了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.