jQuery 移动未定义错误 Cordova。
jQuery mobile undefined error Cordova.
所以我对 Cordova 场景非常陌生,对 jQuery 移动场景更是如此。我只是想让我的应用程序内的事件触发并且感到沮丧,因为我正在做所有文档和教程所说的事情。
这是我的带有样式的脚本布局:
<link rel='stylesheet' href="js/jquery/mobile/jquery.mobile-1.4.5.css" />
<script src="js/jquery/jquery.min.js"></script>
<script src="js/jquery/mobile/jquery.mobile-1.4.5.min.js"></script>
<script src="js/index.js"></script>
jquery 是版本 3.0.0
这是我的 index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.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();
无论我做了什么,无论我如何设置 index.js 或我使用的 jquery 是什么版本(我一直回到 1.10),我仍然得到加载时出现此错误
query.mobile-1.4.5.js:3337 TypeError: undefined is not an object (evaluating 'a.event.props.concat')
这个错误对我来说毫无意义,我通过点击重构并重建了一个简单的 hello world 应用程序,多次但一无所获。我希望有人可以向我解释我做错了什么,或者告诉我一个修复方法,因为没有任何帮助。
您必须在 html 中包含 cordova.js 文件以触发设备就绪事件。看看这个 link - http://cordova.apache.org/docs/en/6.x/cordova/events/events.html#page-toc-source
它确保在调用其组件之前完全加载 Cordova。
所以我对 Cordova 场景非常陌生,对 jQuery 移动场景更是如此。我只是想让我的应用程序内的事件触发并且感到沮丧,因为我正在做所有文档和教程所说的事情。
这是我的带有样式的脚本布局:
<link rel='stylesheet' href="js/jquery/mobile/jquery.mobile-1.4.5.css" />
<script src="js/jquery/jquery.min.js"></script>
<script src="js/jquery/mobile/jquery.mobile-1.4.5.min.js"></script>
<script src="js/index.js"></script>
jquery 是版本 3.0.0
这是我的 index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.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();
无论我做了什么,无论我如何设置 index.js 或我使用的 jquery 是什么版本(我一直回到 1.10),我仍然得到加载时出现此错误
query.mobile-1.4.5.js:3337 TypeError: undefined is not an object (evaluating 'a.event.props.concat')
这个错误对我来说毫无意义,我通过点击重构并重建了一个简单的 hello world 应用程序,多次但一无所获。我希望有人可以向我解释我做错了什么,或者告诉我一个修复方法,因为没有任何帮助。
您必须在 html 中包含 cordova.js 文件以触发设备就绪事件。看看这个 link - http://cordova.apache.org/docs/en/6.x/cordova/events/events.html#page-toc-source
它确保在调用其组件之前完全加载 Cordova。