一、路由模式
-
hash模式
import{ createRouter,createWebHashHistory} from 'vue-router' const router=createRouter({ history:createWebHashHistory(), routes:[ { path:'', compontents: }, { //... } ] })
http://localhost:8080/#/user http://localhost:8080/#/news
如何想把上面的路由改变成下面的方式:
http://localhost:8080/user http://localhost:8080/news
可以使用HTML5 History模式
-
HTML5 HIstory模式
import{ createRouter,createWebHistory} from 'vue-router' const router=createRouter({ history:createWebHistory(), routes:[ { path:'',