为了账号安全,请及时绑定邮箱和手机立即绑定

angularjs1.6.1路由不正确

angularjs1.6.1路由不正确

杨__羊羊 2018-10-12 14:15:43
在使用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请问是什么原因,导致点击链接的时候自动给多加了一个#在!后面?
查看完整描述

1 回答

?
慕的地8271018

TA贡献1796条经验 获得超4个赞

你试试 #!/checkout 。貌似从1.6开始,路由都加了个前缀,默认是 ! 。


查看完整回答
反对 回复 2018-11-15
  • 1 回答
  • 0 关注
  • 490 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号