MicroApp.vue 1.28 KB
<script setup lang="ts">
import { onMounted, onUnmounted, nextTick } 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.getElementById('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>