vue router
使用vite创建项目
npm init vite
vscode配置
- jsconfig.json
{
"include": [
"./src/**/*"
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
安装vue-router
npm i vue-router@4 --save
routes
- 动态组件
const routes = [
{path: '/', name: 'home', component: Home},
{path: '/about', name: 'about',
component: () => import('@/views/About.vue')
},
]
history模式
- HTML5 MODE
- hash mode