我正在使用 jQueryMobile 编写一个移动 Web 应用程序,并放入 AngularJS 来处理数据绑定。但这会在移动设备上引入路由问题。以下是我可以编写的重现问题的最少代码。在桌面上的 Chrome 上一切正常,但是当我从我的 android 设备尝试相同的页面时,我得到了令人讨厌的“错误加载页面”。可以通过使用 data-url 进行导航来解决问题,但有问题。我还需要用电话间隙把它打包起来。这意味着 html 由 file:// 加载,直接导航(data-url)不起作用(我试过)
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script src="https://raw.github.com/tigbro/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter-1.2.0.js"></script>
</head>
<body>
<div data-role="page" id="main">
<a data-role="button" href="#sub">sub</a>
</div>
<div data-role="page" id="sub">
<p>sub page</p>
</div>
</body>
</html>
单击“sub”按钮后,用户应该被定向到 hostname/#sub 并且它在 Chrome 上,但是在 android 上发生了奇怪的事情并且浏览器被路由到 hostname/#!/%23sub 我猜这是 URL 编码的?
另外我应该指出,通过仅删除 angular 和 JQM-angular 适配器的两个脚本引用,一切正常(当然没有数据绑定)。