Files
FiDA_Front/src/router/index.ts

49 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-02-02 13:32:33 +08:00
import { createRouter, createWebHistory } from 'vue-router'
/**
* :
* 1. meta属性为{ cache: true }
* 2. App.vue中使用RouteCache组件name来进行匹配
* 3. name默认是文件名,name不一致,defineOptions({ name: 'componentName' })
*/
const router = createRouter({
history: createWebHistory('/'),
// history: createWebHistory(import.meta.env.VITE_APP_URL),
routes: [
2026-02-02 14:12:23 +08:00
{
path: '/',
redirect: '/home'
},
{
path: '/',
name: 'index',
component: () => import('../views/login/index.vue'),
},
{
path: '/login',
name: 'login',
component: () => import('../views/login/login.vue'),
},
{
path: '/home',
name: 'home',
component: () => import('../views/home/index.vue'),
children: [
{
2026-02-03 11:11:04 +08:00
path: 'test',
2026-02-02 14:12:23 +08:00
name: 'test',
2026-02-03 11:11:04 +08:00
component: () => import('../views/home/test.vue'),
meta: { topNavStyle: '2' }
2026-02-02 14:12:23 +08:00
}
]
},
2026-02-02 13:32:33 +08:00
{
path: '/:pathMatch(.*)',
name: '404',
component: () => import('../views/404.vue'),
2026-02-02 14:12:23 +08:00
}
2026-02-02 13:32:33 +08:00
]
})
export default router