我正在使用PhoneGap& amp; jQuery Mobile。
我已经完成了该应用程序的Android版本。我正在使用Adobe PhoneGap构建来构建我的应用程序。 Android版本运行完美。但现在我正在尝试测试该应用的Windows Phone 8版本。
我在Visual Studio 2012模拟器中测试了PhoneGap构建app.xap
。似乎jQuery mobile不起作用。出于测试目的,我创建了一个示例应用程序。有两个jQuery mobile
页面。那也没有用。
请帮帮我。任何有用的帮助将深表感谢。谢谢,=)请告诉我哪里出错了。
粘贴我的示例代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<!--[if IE 7]><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><![endif]-->
<link rel="stylesheet" href="css/index.css" />
<link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" />
<title>Hello World</title>
</head>
<body>
<div data-role="page" id="page1">
<div data-theme="a" data-role="header">
<h3>
Header
</h3>
</div>
<div data-role="content">
<a data-role="button" href="#page2">
Button
</a>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
<h3>
Footer
</h3>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="content">
<img src="https://maps.googleapis.com/maps/api/staticmap?center=Madison, WI&zoom=14&size=288x200&markers=Madison, WI&sensor=false"
width="288" height="200">
<a data-role="button" href="#page1">
Button
</a>
<div data-role="navbar" data-iconpos="top">
<ul>
<li>
<a href="#page1" data-transition="fade" data-theme="" data-icon="">
Button
</a>
</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="cordova-2.5.0.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.mobile/jquery.mobile-1.2.0.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
这是我得到的输出:
这就是我需要的:
答案 0 :(得分:5)
jQuery Mobile官方不支持Windows Phone 8。请参阅支持的平台:http://jquerymobile.com/gbs/
答案 1 :(得分:0)
按以下方式更改您的页面,并确保模拟器可以访问互联网
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<!--[if IE 7]><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><![endif]-->
<link rel="stylesheet" href="css/index.css" />
<link rel="stylesheet" href="http://jquery.mobile/jquery.mobile-1.1.0.css" />
<script type="text/javascript" src="http://jquery.mobile/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="http://jquery.mobile/jquery.mobile-1.2.0.js"></script>
<script type="text/javascript" src="cordova-2.5.0.js"></script>
<title>Hello World</title>
</head>
<body>
<div data-role="page" id="page1">
<div data-theme="a" data-role="header">
<h3>
Header
</h3>
</div>
<div data-role="content">
<a data-role="button" href="#page2">
Button
</a>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
<h3>
Footer
</h3>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="content">
<img src="https://maps.googleapis.com/maps/api/staticmap?center=Madison, WI&zoom=14&size=288x200&markers=Madison, WI&sensor=false"
width="288" height="200">
<a data-role="button" href="#page1">
Button
</a>
<div data-role="navbar" data-iconpos="top">
<ul>
<li>
<a href="#page1" data-transition="fade" data-theme="" data-icon="">
Button
</a>
</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
答案 2 :(得分:0)
将Cordova文件放在HEAD中并确保它是页面中的第一个JS文件:
JQM在Windows Phone上运行良好...我遇到了与你类似的问题,并修复了它。
答案 3 :(得分:0)
事实上,JQuery mobile在Windows Phone 8中运行良好。
加载js文件的正确顺序是:
加载JQuery本身;仅加载JQuery Mobile css文件;加载自定义脚本和CSS;如果需要,加载phonegap(cordova);加载JQuery Mobile作为最后一个。
此订单适用于任何设备,包括Windows Phone 8(设备或VS2012仿真器) 通常我会在index.html的HEAD部分加载所有这些内容。 如果您有任何疑问,可以使用Cordova模板直接在VS2012中测试您的项目,如here所述
希望得到这个帮助。
答案 4 :(得分:0)
我在Windows8上的VS2012中的WP8模拟器中看到了同样的问题。如果我制作jQuery文件的本地副本就可以了。如果我尝试从CDN加载它们,则不会。
<script type="text/javascript" src="js/jquery.1.7.2.min.js"></script>
WORKS。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
不起作用,看起来没有风格。
我制作了所有Jquery和Jquery移动js和CSS文件的本地副本,我的JQM UI看起来与我期望的完全一样。
尽管如此,如果模拟器的某些白名单功能无法正常工作,我仍然很好奇。或者,如果有超级v交换机管理器的配置无法正常使用。
答案 5 :(得分:0)
我跟着这个link并在VS 2013中安装了phonegap模板。然后我使用phonegap模板和下载的jquery文件创建了一个项目,并将它们包含在我的html文件中,它就像一个魅力:)由于某些原因CDN对Jquery的引用并不适用于Windows Phone模拟器。
以下是您可以参考Jquery的订单,
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.css" />
<!--<script type="text/javascript" src="cordova.js"></script>-->
<script src="js/jquery-1.11.1.js"></script>
<script src="js/jquery.mobile-1.4.2.js"></script>
<title>Hello World</title>
</head>