目前我正在研究 Phonegap,我找到了一个示例代码,我想让它适用于 Phonegap,但我做不到。 我还想提一下,这里使用的是 Jquery MObile 1.2.0,但我想使用 Jquery mobile 1.3.2 和 JQuery 2.1.1,cordova-3.4.0
任何帮助将不胜感激。提前致谢。
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<style>
#content {
padding: 0;
position : absolute !important;
top : 40px !important;
right : 0;
bottom : 40px !important;
left : 0 !important;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
$(document).on('pageinit', '#index',function(e,data){
var minZoomLevel = 12;
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel,
center: new google.maps.LatLng(38.50, -90.50),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
});
</script>
</head>
<body>
<div data-role="page" id="index">
<div data-theme="a" data-role="header">
<h3>
First Page
</h3>
</div>
<div data-role="content" id="content">
<div id="map_canvas" style="height:100%"></div>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
<h3>
First Page
</h3>
</div>
</div>
</body>
</html>
最佳答案
此代码不起作用的原因是您缺少 jQuery 库。没有 jQuery,jQuery Mobile 就无法工作。
这就是您收到此错误的原因:
"Uncaught TypeError: Cannot read property 'mobile' of undefined", source: code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js (2) AND on Android device screen I am getting "First Page" two times in vertical order but there is no map .
关于javascript - 代码不适用于 Phonegap 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24159715/