有人知道“#!”手段。在网址上?
我一直在工作直到那时出现,我在网址中总是有一个“#”,并希望保持这种状态。 目前路由不再工作,可能是因为这个网址更改。
这是商业项目的一部分,我不想改为html5Mode。
我试图使用:
$locationProvider.hashPrefix("");
即使以这种方式更正网址路由也存在问题
答案 0 :(得分:8)
多数人称之为 hash-bang 。
要解决此问题:
<Link to={'/login'} class="Button ">Login</Link>
添加html5Mode甚至可以删除网址中的“#”,但如果刷新页面,则会出现404错误。这可以通过配置您的服务器来解决。为此,您可能需要查看漂亮的小教程:
答案 1 :(得分:0)
您可以在您的位置提供商中使用html5Mode。
$locationProvider.html5Mode(true);
更多信息https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag
答案 2 :(得分:0)
在app.config中设置html5mode
为真
$locationProvider.html5Mode(true).hashPrefix('*');