说,我正在浏览localhost/index.html#/view1
,并且我有一个指向 的链接localhost/index.html
。当我单击它时,通过它的 ng-route 模块对其进行角度处理,它属于我的重定向子句。
这是路线配置的摘录:
$routeProvider
.when( "/view1", route1 )
.otherwise({redirectTo:'/view1'}); // localhost/index.html clicks fall here
我可以使用 ng-click,然后使用 location.href 以 javascript 方式重定向,但这不是一个理想的解决方案,因为我会丢失 href 链接(SEO、书签、标签)。
tl;博士
如何告诉 angularJs ng-route 不要处理没有 hash 的 url?
编辑:我不使用 html5 模式,也不打算使用它。