vite-plugin-qiankun icon indicating copy to clipboard operation
vite-plugin-qiankun copied to clipboard

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

Open JD-Wang opened this issue 2 years ago • 4 comments

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

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

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

JD-Wang avatar May 20 '22 06:05 JD-Wang

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

Relaxe111 avatar Jul 21 '22 09:07 Relaxe111

any update?

mieco avatar Sep 07 '22 03:09 mieco

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

Relaxe111 avatar Sep 07 '22 05:09 Relaxe111

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.

mieco avatar Sep 14 '22 04:09 mieco