From 7a4daf2c864d318d5f5924295447e8b9d1c35df9 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Thu, 22 Apr 2021 19:38:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E6=B2=A1=E6=9C=89=20getApp=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/remax-runtime/src/createPageConfig.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/remax-runtime/src/createPageConfig.ts b/packages/remax-runtime/src/createPageConfig.ts index 97dfa7c70..a10812541 100644 --- a/packages/remax-runtime/src/createPageConfig.ts +++ b/packages/remax-runtime/src/createPageConfig.ts @@ -20,7 +20,12 @@ export function resetPageId() { } export default function createPageConfig(Page: React.ComponentType, name: string) { - const app = getApp() as any; + let app: any; + try { + app = getApp(); + } catch (e) { + app = null; + } const config: any = { data: { @@ -74,7 +79,9 @@ export default function createPageConfig(Page: React.ComponentType, name: s this.callLifecycle(Lifecycle.unload); this.unloaded = true; this.container.clearUpdate(); - app._unmount(this); + if (app) { + app._unmount(this); + } }, onTabItemTap(this: any, e: any) {