MicroApp.vue
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import GlobalLoading from "@/components/GlobalLoading.vue";
const route = useRoute();
onMounted(async () => {
console.log("[基座] 微应用容器组件已挂载,当前路由:", route.path);
// 等待 DOM 完全更新
await nextTick();
// 确认容器元素已存在
const container = document.querySelector("#subapp-container");
if (container) {
console.log("[基座] 微应用容器 DOM 已就绪");
} else {
console.error("[基座] 微应用容器 DOM 未找到,可能导致微应用加载失败");
}
});
onUnmounted(() => {
console.log("[基座] 微应用容器已卸载");
});
</script>
<template>
<div class="micro-app-wrapper">
<!-- qiankun 微应用容器 - 作为唯一的微应用挂载点 -->
<div id="subapp-container" class="micro-app-container"></div>
<!-- 子应用加载中的 loading -->
<GlobalLoading />
</div>
</template>
<style scoped>
.micro-app-wrapper {
position: relative;
width: 100%;
height: 100%;
min-height: 500px;
}
.micro-app-container {
width: 100%;
height: 100%;
min-height: 500px;
/* 移除内边距,让微应用完全填充容器 */
padding: 0;
margin: 0;
}
</style>