From 77e074d03ab75775e40278c6f38c2cb21d7ef935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E7=BA=AF?= Date: Thu, 25 Mar 2021 15:23:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(qiankun):=20=20=E5=88=87=E5=87=BA=E5=AD=90?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=97=B6=EF=BC=8C=E5=9B=A0=E4=B8=BAapp?= =?UTF-8?q?=E6=98=AF=E5=BC=82=E6=AD=A5=E6=95=B0=E6=8D=AE=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=9C=AA=E5=8F=8A=E6=97=B6unmount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fes-plugin-qiankun/src/micro/runtime/lifecycles.tpl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/fes-plugin-qiankun/src/micro/runtime/lifecycles.tpl b/packages/fes-plugin-qiankun/src/micro/runtime/lifecycles.tpl index 4c71315d..0bebf7c1 100644 --- a/packages/fes-plugin-qiankun/src/micro/runtime/lifecycles.tpl +++ b/packages/fes-plugin-qiankun/src/micro/runtime/lifecycles.tpl @@ -16,7 +16,7 @@ function isPromise(obj) { let render = () => {}; -let app = null; +let cacheAppPromise = null; let hasMountedAtLeastOnce = false; export default () => defer.promise; @@ -40,7 +40,7 @@ export function genBootstrap(oldRender, appPromise) { } render = oldRender; if (isPromise(appPromise)) { - app = await appPromise; + cacheAppPromise = appPromise; } }; } @@ -63,7 +63,7 @@ export function genMount() { if (hasMountedAtLeastOnce) { const appPromise = render(); if (isPromise(appPromise)) { - app = await appPromise; + cacheAppPromise = appPromise; } } else { defer.resolve(); @@ -93,7 +93,8 @@ export function genUnmount(mountElementId) { ? props.container.querySelector(mountElementId) : document.querySelector(mountElementId); } catch (e) {} - if (container && app) { + if (container && cacheAppPromise) { + const app = await cacheAppPromise; app.unmount(container); } const slaveRuntime = getSlaveRuntime();