AngularJS路由刪除#符號解決方案

最近做一個web應用,有個需求需要刪除angular路由中的#號。

例如:

http://example.com/
http://example.com/#/about
http://example.com/#/contact

需要改成

http://example.com/
http://example.com/about
http://example.com/contact

這個是angular默認自帶的,所以想要刪除需要配置一下:

$locationProvider.html5Mode(true);

然後再index.html 的header中,指定一個base:

<base href="/">

這就ok了,需要的通知自己嘗試一下吧!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章