vue router

使用vite创建项目

npm init vite

vscode配置

  1. 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
posted @ 2022-08-28 21:25  fight139  阅读(14)  评论(0编辑  收藏  举报