前言
以前我們用的路由都是以拋錨形式的擦秽,想不到現(xiàn)在可以做成像偽靜態(tài)一樣的路由。
示例對(duì)比
傳統(tǒng)形式(hash式)的路由:
http://www.example.com/app#index
http://www.example.com/app#user
vue式(URL式)路由:
http://www.example.com/app/index
http://www.example.com/app/user
這里要注意的是,這個(gè)需要配合后端服務(wù)器的配置才能實(shí)現(xiàn)的了。
如果用的是nginx 何恶,則需要加上配置:
location / {
try_files $uri $uri/ /index.html;
}
參考
vue官方路由管理器
https://router.vuejs.org/zh/guide/essentials/history-mode.html