Vue Router安装
yarn add vue-router@4
修改配置
app.vue
<template>
<transition name="el-fade-in-linear"><router-view></router-view></transition>
</template>
<script></script>
<style></style>
创建router文件夹下新建index.ts
index.ts
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
{
path: '/',
redirect: '/login',
},
{
path: '/login',
name: 'login',
component: () =>
import(/* webpackChunkName: "index" */ '@/pages/login/myLogin.vue'),
},
];
const router = createRouter({
history: createWebHistory(),
routes: routes,
});
export default router;