Vue Router 官网
** https://router.vuejs.org/zh**
安装
** npm install vue-router@4**
代码
** demo\src\router\index.js**
`import { createRouter, createWebHashHistory, createWebHistory } from "vue-router"
const routes = [
{
path: "/", // http://localhost:5173
component: () => import("../views/index.vue")
},
{
path: "/content", // http://localhost:5173/content
component: () => import("../views/content.vue")
},
]
const router = createRouter({
//使用url的#符号之后的部分模拟url路径的变化,因为不会触发页面刷新,所以不需要服务端支持
//history: createWebHashHistory(),
history: createWebHistory(),
routes
})
export default router`
标签:5173,Vue,Router4,content,vue,import,router,路由
From: https://www.cnblogs.com/dengtiancode/p/18222119