import {createRouter, createWebHashHistory} from "vue-router";
// 1. 配置路由
let routes = [
{ path: '/', redirect: '/login' },
{
path: '/login', component: () => import('../views/login.vue')
},
{
path: '/index', component: () => import('../views/index.vue'),
children: [
{
path: '/user',
name: "user",
components:{ user: () => import('../views/system/user.vue')}
},
{
path: '/role',
name: "role",
components:{ role: () => import('../views/system/role.vue')}
},
{
path: '/menu',
name: "menu",
components: { menu: () => import('../views/system/menu.vue')}
}
],
},
];
// 2.返回一个 router 实列,为函数,配置 history 模式
const router = createRouter({
history: createWebHashHistory(),
routes,
});
// 3.导出路由 去 main.ts 注册 router.ts
export default router