如何从url MEAN STACK中删除#tag

问题描述 投票:0回答:2

嗨,我正在使用Mean堆栈的Web应用程序问题是包含#的网址!

就像是

 http://host:3000/#!/signup 

我希望网址像

  http://host:3000/signup 

这该怎么做。

angularjs node.js mongodb elasticsearch meanjs
2个回答
4
投票

$routeProvider中,使用HTML5 History API:

$ locationProvider.html5Mode(真);

设置相关链接:

要使用相对链接链接您的应用程序,您需要在文档的<base>中设置<head>

<!doctype html>
<html>
<head>
    <meta charset="utf-8">

    <base href="/">
</head>

你可以在这里详细阅读:Pretty URLs in AngularJS: Removing the #

希望这可以帮助。


0
投票

通过添加以下代码为$locationProvider启用HTML5

 $locationProvider.html5Mode(true).hashPrefix('!');
© www.soinside.com 2019 - 2024. All rights reserved.