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"

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