为什么会有#!在我的角度应用程序的网址中 [英] Why is there #! in the url of my angular app

查看:89
本文介绍了为什么会有#!在我的角度应用程序的网址中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些未知原因,在Visual Studio 2015中进行调试时,我已将 '#!' 添加到我的应用程序网址中.

for some unknown reason, I have '#!' added to my apps url when debugging in visual studio 2015.

网址看起来像这样

http://localhost:58394/#!/customers
http://localhost:58394/#!/

如果这是某种错字,我已经搜索了所有应用程序,但是我不知道这是哪里来的.

I have searched all app if this is some sort of typo, but I cannot figure out where is this comming from.

我可以在ASP.NET WEB API以及ASP.NET CORE WEB API中看到这一点...

I can see that in ASP.NET WEB API as well as in ASP.NET CORE WEB API...

对于前端,我使用角度和角度路线 1.6.0

For front end I'm using angular and angular-route 1.6.0

任何想法是从哪里来的?

Any ideas where is this comming from?

我没有使用html5mode或base标记,但我很高兴现在能出现在#那里,我只是不明白为什么其中包含感叹号(!)...

I'm not using html5mode nor base tag and I'm happy for # to be there for now, I just don't understand why is the exclamation mark (!) in there ...

此应用程序不可部署在网络上,并且未使用任何可能使用#!的外部服务!跟踪或其他任何符号.

This app is not to be deployed on web and is not using any external service which could possibly use #! notation for any tracking or anything else.

最近,惊叹号开始出现,所以我想这是由我正在使用的某些libs引起的.

The exclamation mark started to apear after the hast just recently so I guess this is caused by some the libs I'm using.

我只想知道为什么存在'!',以及在其中强制执行此惊叹号的库.

I just would like to know why '!'is there and what library it forcing this exclamation there.

推荐答案

我已经在angualr 1.6.0更新日志中找到了这个

I have found this in angualr 1.6.0 changelog

$ location:默认hashPrefix为'!' (aa077e,#13812)

$location: default hashPrefix to '!' (aa077e, #13812)

更改日志: https://github.com/angular/angular .js/blob/master/CHANGELOG.md

更改: https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52

BREAKING CHANGE

BREAKING CHANGE

$location哈希爆炸URL的哈希前缀已与 空字符串"到爆炸!".如果您的应用程序不使用 HTML5模式或正在不支持HTML5模式的浏览器上运行, 并且您还没有指定自己的哈希前缀,则没有指定客户端URL 现在将包含一个!"字首.例如,而不是 mydomain.com/#/a/b/c将成为mydomain/#!/a/b/c.

The hash-prefix for $location hash-bang URLs has changed from the empty string "" to the bang "!". If your application does not use HTML5 mode or is being run on browsers that do not support HTML5 mode, and you have not specified your own hash-prefix then client side URLs will now contain a "!" prefix. For example, rather than mydomain.com/#/a/b/c will become mydomain/#!/a/b/c.

仅需使用

appModule.config(['$locationProvider', function($locationProvider) {
    $locationProvider.hashPrefix('');
}]);

这篇关于为什么会有#!在我的角度应用程序的网址中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆