2025年01月05日 建站教程
vue3开发中如何利用vue-router设置路由,下面web建站小编给大家简单介绍一下!
1、安装vue-router
npm install vue-router@4.0.0-beta.13
2、设置路由文件
import { createRouter, createWebHashHistory } from "vue-router"
const routes = [
{
path: '/',
component: () => import('@/index')
},
{
path: '/list',
name: "list",
component: () => import('@/pages/list')
},
{
path: '/about',
name: "about",
component: () => import('@/pages/about')
},
]
export const router = createRouter({
history: createWebHashHistory(),
routes: routes
})
export default router
本文链接:http://so.lmcjl.com/news/20765/