[英]jQuery mobile undefined error Cordova.
因此,對於Cordova場景,我還是一個新手,對於jQuery Mobile場景,我更是陌生。 我只是想讓我的事件在應用程序中觸發,並感到沮喪,因為我正在按照所有文檔和教程所說的去做。
這是我的樣式腳本布局:
<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文件以觸發deviceready事件。 查看此鏈接-http://cordova.apache.org/docs/en/6.x/cordova/events/events.html#page-toc-source
它可確保在調用其組件之前完全加載Cordova。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.