在使用angular-route設置路由時,頁面href不正確,如下:[app.html]
...
<custom />
...
<script>
...
app.config(["$routeProvider", function ($routeProvider) {
$routeProvider.when("/checkout", {
templateUrl: "views/checkoutSummary.html",
});
$routeProvider.when("/products", {
templateUrl: "views/productList.html"
});
$routeProvider.otherwise({
templateUrl: "/views/productList.html",
})
}])
...
</script>custom指令引入模版如下(由于只有路由有問題,這里的代碼不包含沒有問題的代碼):<div class="navbar-right">
<div class="navbar-text">
<b>購物車:</b>
{{itemCount()}} 個商品, {{total() | currency}}
</div>
<a href="#/checkout" class="btn btn-default navbar-btn">結算</a></div>點擊a元素時,瀏覽器路徑顯示為:http://localhost:3000/app.html#!#%2Fcheckout錯誤路徑取到的$location.hash()為"/checkout"正確的路徑應為:http://localhost:3000/app.html#!/checkout或者http://localhost:3000/app.html#!%2Fcheckout請問是什么原因,導致點擊鏈接的時候自動給多加了一個#在!后面?
angularjs1.6.1路由不正確
楊__羊羊
2018-10-12 14:15:43