tengmaoqing / vite-plugin-qiankun

保留vite es特性,快速接入乾坤微前端子应用
MIT License
466 stars 84 forks source link

可以支持多个子应用同步加载吗 #27

Open JD-Wang opened 2 years ago

JD-Wang commented 2 years ago

loadMicroApp调用多个子应用,子应用html加载完后就会进行global.qiankunName赋值,全局的global.qiankunName 只能设置一个,renderWithQiankun执行时就会导致只执行最后设置qiankunName 的子应用,其他的子应用生命周期不会被执行

现在只能同步阻塞解决 loadMicroApp({ ... // 子应用1 }).bootstrapPromise.then(() => { loadMicroApp({ ... // 子应用2 }) })

那有办法支持同时并发加载多个vue3的子应用吗?

Relaxe111 commented 2 years ago

@JD-Wang did you found any solution for you're issue?

mieco commented 2 years ago

any update?

Relaxe111 commented 2 years ago

i have found a kind of work around but biggest drawback is that one need to add 4 line of code in qiankun lib and 2 in this plugin

mieco commented 2 years ago

I found that the hooks don't work because I import vue-global-api in my project, it mounts the hooks to the window object, so when another sub-app call such as the onMounted, it will trigger the global onMounted method that context is wrong. I use unplugin-auto-import/vite plugin instead, and it works now. hope it can help someone.