配置好了vue2的子应用接入
This commit is contained in:
29
src/router/index.ts
Normal file
29
src/router/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/home'
|
||||
},
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('@/views/Home.vue')
|
||||
},
|
||||
{
|
||||
// 子应用路由 — `:page*` 通配符匹配子应用内部所有路由
|
||||
// 例如:/child-app、/child-app/page1、/child-app/page2/xxx
|
||||
path: '/child-app/:page*',
|
||||
name: 'childApp',
|
||||
component: () => import('@/views/ChildApp.vue')
|
||||
}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
// history 模式 — 主应用和子应用都使用 history 模式
|
||||
// 通过 baseroute 区分路由归属
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user