AngularJS ui路由器应用程序的URL中包含/#!/ [英] AngularJS ui-router application has /#!/ in the URL

查看:81
本文介绍了AngularJS ui路由器应用程序的URL中包含/#!/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ui.router 正常运行的应用程序,但是另一个应用程序的URL在#"

I have an application with ui.router working normally, but another application the url has an "!" after "#"

例如:http://localhost:8090/dev/#!/home

为什么会这样?

正常值应为:http://localhost:8090/dev/#/home

推荐答案

我想发生这种情况是因为未设置hashprefix.

I suppose this happens because hashprefix is not set.

$locationProvider
  .hashPrefix('!');

我想您可以将其设置为空字符串,这就是为什么您看不到!的原因.

I guess you can set it to empty string and that is why you don't see !.

或者,您可以完全启用html5mode that will get rid of hashbang`.某些较旧的浏览器不支持它,但通常不成问题,除非您需要支持IE9或其他功能.

Alternatively you can enable html5modethat will get rid ofhashbang` completely. Some older browsers don't support it, but generally not an issue, unless you need to support IE9 or something.

您可以阅读有关此内容的信息,例如此处

You can read about it e.g. here or here.

长话短说,如果您正确配置了html5mode,那么您将没有在不支持该功能的旧版浏览器中进行路由所需的hashbang.

Long story short if you configure html5mode properly, then you won't have the hashbang that is required for routing in older browsers that do not support it.

这篇关于AngularJS ui路由器应用程序的URL中包含/#!/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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