您好3天前我正在使用phonegap构建它工作正常但昨天当我从phonegap构建器创建新构建时它停止工作并获取数据。仅适用于手机屏幕。
以下是我的配置代码。
<!-- Customize your app and platform with the preference element. -->
<preference name="orientation" value="default" /> <!-- all: default means both landscape and portrait are enabled -->
<preference name="target-device" value="universal" /> <!-- all: possible values handset, tablet, or universal -->
<preference name="fullscreen" value="true" /> <!-- all: hides the status bar at the top of the screen -->
<preference name="webviewbounce" value="true" /> <!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
<preference name="prerendered-icon" value="true" /> <!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen -->
<preference name="stay-in-webview" value="false" /> <!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in -->
<preference name="ios-statusbarstyle" value="black-opaque" /> <!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar -->
<preference name="detect-data-types" value="true" /> <!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->
<preference name="exit-on-suspend" value="false" /> <!-- ios: if set to true, app will terminate when home button is pressed -->
<preference name="show-splash-screen-spinner" value="true" /> <!-- ios: if set to false, the spinner won't appear on the splash screen during app loading -->
<preference name="auto-hide-splash-screen" value="true" /> <!-- ios: if set to false, the splash screen must be hidden using a JavaScript API -->
<preference name="disable-cursor" value="false" /> <!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app -->
<preference name="android-installLocation" value="auto" /> <!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. -->
<!--
Define a specific version of PhoneGap to build into your app.
<preference name="phonegap-version" value="3.5.0" />
-->
<!-- Plugins -->
<!-- Core plugins -->
<gap:plugin name="org.apache.cordova.console" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.network-information" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<!-- Third party plugins -->
<!-- A list of available plugins are available at https://build.phonegap.com/plugins -->
<!--
<gap:plugin name="com.phonegap.plugins.barcodescanner" />
-->
<!-- Define app icon for each platform. -->
<icon src="icon.png" />
<icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:qualifier="ldpi" />
<icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:qualifier="mdpi" />
<icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:qualifier="hdpi" />
<icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:qualifier="xhdpi" />
<icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" />
<icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" gap:state="hover"/>
<icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57" />
<icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114" />
<icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144" />
<icon src="res/icon/webos/icon-64.png" gap:platform="webos" />
<icon src="res/icon/windows-phone/icon-48.png" gap:platform="winphone" />
<icon src="res/icon/windows-phone/icon-173.png" gap:platform="winphone" gap:role="background" />
<!-- Define app splash screen for each platform. -->
<gap:splash src="res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:qualifier="port-ldpi" />
<gap:splash src="res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:qualifier="port-mdpi" />
<gap:splash src="res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:qualifier="port-hdpi" />
<gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:qualifier="port-xhdpi" />
<gap:splash src="res/screen/blackberry/screen-225.png" gap:platform="blackberry" />
<gap:splash src="res/screen/ios/screen-iphone-portrait.png" gap:platform="ios" width="320" height="480" />
<gap:splash src="res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios" width="640" height="960" />
<gap:splash src="res/screen/ios/screen-iphone-portrait-568h-2x.png" gap:platform="ios" width="640" height="1136" />
<gap:splash src="res/screen/ios/screen-ipad-portrait.png" gap:platform="ios" width="768" height="1024" />
<gap:splash src="res/screen/ios/screen-ipad-landscape.png" gap:platform="ios" width="1024" height="768" />
<gap:splash src="res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone" />
<gap:config-file platform="ios" parent="CFBundleShortVersionString">
<string>100</string>
</gap:config-file>
<!--
Define access to external domains.
<access /> - a blank access tag denies access to all external resources.
<access origin="*" /> - a wildcard access tag allows access to all external resource.
Otherwise, you can specify specific domains:
<access origin="http://phonegap.com" /> - allow any secure requests to http://phonegap.com/
<access origin="http://phonegap.com" subdomains="true" /> - same as above, but including subdomains, such as http://build.phonegap.com/
<access origin="http://phonegap.com" browserOnly="true" /> - only allows http://phonegap.com to be opened by the child browser.
-->
<access origin="*"/>
<!-- Added the following intents to support the removal of whitelist code from base cordova to a plugin -->
<!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
以下是我的jquery代码
$(document).on("pagecreate","#login",function(){
$("#loginForm").submit(function(e) {
e.preventDefault();
var a = $(this).serializeArray();
var un = a[0]['value'];
var pw = a[1]['value'];
$.ajax({
type: "get",
url: 'http://animap.azurewebsites.net/json/login_json.php',
crossDomain: true,
dataType: 'json',
data: {
email: un,
pass: pw
},
success: function(data)
{
//var a = JSON.parse(data);
alert(data[0]);
if (data[0] == 'success') {
$.mobile.changePage( "#tracker-options", { transition: "slideup", changeHash: true });
$("#user").text(un);
user = un;").hide();
return false;
}
else {
$("#alert").show();
}
},
error: function(xhr, status, error) {
alert('Failed!');
alert(xhr.statusText);
alert(xhr.responseText);
}
});
return false; // avoid to execute the actual submit of the form.
});
});
虽然这个相同的代码与cordova工作正常,但我认为配置文件存在一些问题但无法解决。
答案 0 :(得分:2)
@nirmal,
你遇到了一个常见的错误。这是一份可以帮助您的文件:
Cordova / Phonegap新手的开发人员的首要错误
https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/new-to-Phonegap.md
你已经点击了:
对于#6&amp; #7
使用CLI版本,如果您没有为您的平台分配版本,或者如果您未在config.xml中设置phonegap-version,则在“Phonegap Build”中,您将获得最新版本。如果运气好,您的程序就会按预期运行。如果你不幸运,你会得到一套cascasding错误。
幸运的是,对于我们所有人来说,Holly Schinsky写了一篇很好的博文来解释这一切:
Cordova / PhoneGap版本混淆
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/
#10
这个相对*新*要求意味着 - 要访问网络上的任何网站或资源,您必须使用白名单和白名单插件。如果您使用cordova-android@4.0.0或更高版本,此要求将生效;包括cli-5.1.1。
要明确的是,“白名单”已经存在了一段时间,但插件和要求非常新。正如您所料,当添加“白名单”时,不推荐使用事实上的开放访问功能。或者说另一种方式,事实上开放访问功能已被计划并计划被淘汰。此更改标志着删除开放访问功能的一个步骤。
Phonegap Build Forum:Notes for upgrading to cli-5.1.1 on PGB,现在需要白名单
最好的运气