问题
访问路径的时候,会出现#
,想去除
import { createRouter, createWebHashHistory } from "vue-router"
import Auth from "../views/Auth.vue"
// 定义路由
const routers = [{
path:"/",
redirect:"/auth"
},{
path:"/auth",
name:"auth",
component:Auth
}]
// 创建router实例
const router = createRouter({
history:createWebHashHistory(),
routes:routers
})
// 导出router实例
export default router
解决策略
import { createRouter, createWebHistory } from "vue-router"
import Auth from "../views/Auth.vue"
// 定义路由
const routers = [{
path:"/",
redirect:"/auth"
},{
path:"/auth",
name:"auth",
component:Auth
}]
// 创建router实例
const router = createRouter({
history:createWebHistory (),
routes:routers
})
// 导出router实例
export default router