cordova项目中是否需要index.js?
我必须保留这个文件(www/js/index.js),还是可以删除它并放进我的项目文件cordova项目中是否需要index.js?,cordova,Cordova,我必须保留这个文件(www/js/index.js),还是可以删除它并放进我的项目文件 var app = { // Application Constructor initialize: function() { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }, // deviceready Event Handler /
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
this.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
我以前使用Cocoon.io,没有index.js文件,我自己处理deviceready事件。只要您正确绑定了
deviceready
事件,您就可以完全替换或删除index.js
。确保您也从index.html
中相应地更新JS引用
如果在测试应用程序时什么都不起作用,那就意味着你已经破坏了
ondevicerady
处理程序。“只要你是…,…完全删除index.js
”,index.js不是服务器的吗?我不太明白。。。