[英]jQueryMobile routing not working with AngularJS
我正在用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”按鈕后,應該將用戶定向到主機名/#sub,它在Chrome上,但是奇怪的事情在android上發生,瀏覽器路由到主機名/#!/%23sub,我想這是URL編碼嗎?
我還要指出,通過僅刪除angular和JQM-angular適配器的兩個腳本防護,一切正常(當然也沒有數據綁定)。
我試着刪除angular-jquery適配器,並且一切正常,就好像靠魔術一樣。 角度和jQuery沖突也沒有問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.