vue2去/#的方式
在路由配置文件中增加mode:"history"
1 export default new Router({ 2 mode: 'history', 3 routes: [ 4 { 5 xxxxxx 6 } 7 ] 8 })
vue3去/#的方式
原來的路由配置文件
import { createRouter, createWebhashHistory } from "vue-router"
const routes = [
xxxxxxx
]
const router = createRouter({
history: createWebhashHistory(),
routes: routes
})
export default router
將原來的createWebhashHistory,統一改為createWebHistory就好了
import { createRouter, createWebHistory } from "vue-router"
const routes = [
xxxxxxx
]
const router = createRouter({
history: createWebHistory(),
routes: routes
})
export default router