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

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

问题描述

出于某种未知原因,在 Visual Studio 2015 中进行调试时,我将 '#!' 添加到我的应用程序 URL 中.

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...

对于前端,我使用 angular 和 angular-route 1.6.0

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

任何想法来自哪里?

我既没有使用 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.

感叹号在最近刚刚开始出现,所以我想这是由我正在使用的一些库引起的.

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

重大变化

$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.

要恢复到旧的方式只需使用

to revert to the old way just use

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

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

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