angularjs ui-router路由移除#解决方案

  1. ui-router中增加

$locationProvider.html5Mode(true);

   2.根目录增加.htaccess文件,并增加

RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

   3.在index.html的head标签中增加

<base href="/">

   4.若刷新页面后样式失效,请查看是否路径为"./abc"写法,改写成绝对路径"/abc"

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