AngularJS 1.1.5 - 自动添加散列标签为URL [英] AngularJS 1.1.5 - automatically adding hash tag to URLs
问题描述
有谁知道为什么1.1.5版自动添加包括hashtag到你的网址,以及如何关闭这个功能? IMO这是难看。只要你有不以正斜杠结尾的URL它发生。 (我不使用路由或类似的东西)。
Does anyone know why version 1.1.5 automatically adds a hashtag to your urls, and how to turn this off? IMO this is ugly looking. It happens whenever you have a url that doesn't end in a forward slash. (I'm not using routes or anything like that).
所以这个:
http://my.website.com/about
变为
http://my.website.com/about#/about
和这样的:
http://my.website.com/about.html
变成了:
http://my.website.com/about.html#/about.html
但这:
http://my.website.com/about/
不存在这个问题。
doesn't have this problem.
推荐答案
我遇到过这个问题,只是一天。我通过启用HTML5模式 $ locationProvider
解决它。参见 文档为$位置 - HTML5模式线 < A HREF =https://docs.angularjs.org/guide/$location#-location-service-configuration相对=nofollow>更新链接$位置 - HTML5模式
I experienced this issue just the other day. I solved it by enabling HTML5 mode for $locationProvider
. See Docs for $location - HTML5 Mode Updated link for $location - HTML5 Mode.
应该类似于此:
.config(['$locationProvider', function($locationProvider){
$locationProvider.html5Mode(true).hashPrefix('!');
}]);
这篇关于AngularJS 1.1.5 - 自动添加散列标签为URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!