接入vue3子应用
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
.idea
|
||||||
*.local
|
*.local
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
1247
docs/micro-app多子应用接入实战.md
Normal file
1247
docs/micro-app多子应用接入实战.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
|||||||
<nav class="nav-links">
|
<nav class="nav-links">
|
||||||
<router-link to="/home">首页</router-link>
|
<router-link to="/home">首页</router-link>
|
||||||
<router-link to="/child-app">Vue2 子应用</router-link>
|
<router-link to="/child-app">Vue2 子应用</router-link>
|
||||||
|
<router-link to="/vue3-app">Vue3 子应用</router-link>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main class="app-main">
|
<main class="app-main">
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ export const subApps: SubAppConfig[] = [
|
|||||||
iframe: true,
|
iframe: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
routerMode: 'native'
|
routerMode: 'native'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'vue3-app',
|
||||||
|
url: 'http://localhost:3001/',
|
||||||
|
baseroute: '/vue3-app',
|
||||||
|
// Vite 子应用必须开启 iframe 沙箱
|
||||||
|
iframe: true,
|
||||||
|
keepAlive: true,
|
||||||
|
routerMode: 'native'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,23 @@ const routes = [
|
|||||||
name: 'home',
|
name: 'home',
|
||||||
component: () => import('@/views/Home.vue')
|
component: () => import('@/views/Home.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/about',
|
||||||
|
name: 'about',
|
||||||
|
component: () => import('@/views/About.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// 子应用路由 — `:page*` 通配符匹配子应用内部所有路由
|
// 子应用路由 — `:page*` 通配符匹配子应用内部所有路由
|
||||||
// 例如:/child-app、/child-app/page1、/child-app/page2/xxx
|
// 例如:/child-app、/child-app/page1、/child-app/page2/xxx
|
||||||
path: '/child-app/:page*',
|
path: '/child-app/:page*',
|
||||||
name: 'childApp',
|
name: 'childApp',
|
||||||
component: () => import('@/views/ChildApp.vue')
|
component: () => import('@/views/ChildApp.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Vue3 子应用路由
|
||||||
|
path: '/vue3-app/:page*',
|
||||||
|
name: 'vue3App',
|
||||||
|
component: () => import('@/views/ChildApp.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
11
src/views/About.vue
Normal file
11
src/views/About.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>主应用的about</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user