diff --git a/src/create_app.ts b/src/create_app.ts index b6b3f199e..31c2b3aeb 100644 --- a/src/create_app.ts +++ b/src/create_app.ts @@ -664,7 +664,7 @@ export default class CreateApp implements AppInterface { } private getMicroAppGlobalHook (eventName: string): Func | null { - const listener = (this.sandBox?.proxyWindow as Record)[eventName] + const listener = (this.sandBox?.proxyWindow as Record)?.[eventName] return isFunction(listener) ? listener : null } diff --git a/src/sandbox/iframe/index.ts b/src/sandbox/iframe/index.ts index 1fad0c45a..107f9d6a6 100644 --- a/src/sandbox/iframe/index.ts +++ b/src/sandbox/iframe/index.ts @@ -98,7 +98,7 @@ export default class IframeSandbox { // TODO: 优化代码 // exec before initStaticGlobalKeys this.createProxyLocation(appName, url, this.microAppWindow, childStaticLocation, browserHost, childHost) - this.createProxyWindow(appName, this.microAppWindow) + this.createProxyWindow(this.microAppWindow) this.initStaticGlobalKeys(appName, url) // get escapeProperties from plugins this.getSpecialProperties(appName) @@ -405,7 +405,7 @@ export default class IframeSandbox { ) } - private createProxyWindow (appName: string, microAppWindow: microAppWindowType): void { + private createProxyWindow (microAppWindow: microAppWindowType): void { const rawWindow = globalEnv.rawWindow this.proxyWindow = new Proxy(microAppWindow, { get: (target: microAppWindowType, key: PropertyKey): unknown => {