1

我在 jqm + phonegap 应用程序中使用以下 Cordova 文件。

http://clubbedinapp.com/jsa/cordova.js

当应用程序打开时,会出现如下警报:

在此处输入图像描述

此外,页面只是冻结,不允许我做任何事情。

如何修复此错误?

index.html 中的一些代码:

<link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css"/>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>

<!-- The following must be AFTER jquery core and BEFORE jquery mobile js -->
<script type="text/javascript">
    $(document).on("mobileinit", function() {
    $.mobile.touchOverflowEnabled = true; // required
    $.mobile.defaultPageTransition = 'none'; // optional - for better performance on Android
    $.mobile.defaultDialogTransition = 'none';
    $.mobile.loadingMessageTextVisible = true; // optional - added to show text message
    $.mobile.buttonMarkup.hoverDelay = 0; // optional added to remove sluggishness - jqm default 200
    $.mobile.allowCrossDomainPages = true;
    $.support.cors = true;
    });

// Wait for PhoneGap to load
document.addEventListener("deviceready", onDeviceReady, false);

// PhoneGap is ready
function onDeviceReady() {
// Do cool things here...
}

function getImage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(uploadPhoto, function(message) {
alert('Get Picture Failed. Please Try Again.');
},{
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
}
);

}

function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=curClub+imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";

var params = new Object();
params.value1 = "test";
params.value2 = "param";
params.clubID = curClub ;
options.params = params;
options.chunkedMode = false;

var ft = new FileTransfer();
ft.upload(imageURI, "url", win, fail, options);
}

function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);;
}

function fail(error) {
alert("An error has occurred: Code = " = error.code);
}
</script>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<link rel="stylesheet" href="css/latest.css"/>
<script src="js/latest.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.validate.min.js"></script>
<link rel="stylesheet" href="css/jqm-datebox.min.css" />
<link rel="stylesheet" href="css/jquery.mobile.simpledialog.min.css" />
<link rel="stylesheet" href="jquery.mobile.flatui.css" />
<script type="text/javascript" charset="utf-8" src="js/jqm-datebox.core.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.mobile.simpledialog2.min.js"></script>
4

1 回答 1

1

在使用其 API之前,您必须包含 Cordova 库。

根据评论,如果您使用 PhoneGap Build 创建可安装文件,则还必须不包含 cordova.js 文件。

于 2013-09-16T00:09:12.723 回答