@@ -89,7 +89,6 @@ export struct RNCWebView {
8989
9090 aboutToAppear() {
9191 try {
92- this.eventEmitter = new RNC.RNCWebView.EventEmitter(this.ctx.rnInstance, this.tag)
9392 this.initVariable()
9493 this.url = this.source.uri as string;
9594 webview.WebviewController.setWebDebuggingAccess(this.descriptorWrapper.props.webviewDebuggingEnabled)
@@ -109,7 +108,6 @@ export struct RNCWebView {
109108 }
110109 })
111110 }
112- this.webViewBaseOperate = BaseOperate.getInstance(this.eventEmitter, this.controller)
113111 } catch (error) {
114112 Logger.error(TAG, `[RNOH]Errorcode: ${error.code}, Message: ${error.message}`);
115113 }
@@ -360,6 +358,13 @@ export struct RNCWebView {
360358 this.webViewBaseOperate?.ignoreSilentHardwareSwitchMethods(ignoreSilentHardwareSwitch)
361359 }
362360
361+ controllerAttachedInit(): void {
362+ this.controllerAttached = true;
363+ this.eventEmitter = new RNC.RNCWebView.EventEmitter(this.ctx.rnInstance, this.tag)
364+ this.webViewBaseOperate = BaseOperate.getInstance(this.eventEmitter, this.controller)
365+ this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
366+ }
367+
363368 build() {
364369 Stack() {
365370 Web({ src: "", controller: this.controller, renderMode: this.renderMode })
@@ -433,8 +438,7 @@ export struct RNCWebView {
433438 }
434439 })
435440 .onControllerAttached(() => {
436- this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
437- this.controllerAttached = true;
441+ this.controllerAttachedInit()
438442 Logger.debug(TAG, "[RNOH] onControllerAttached")
439443 let baseUrl = this.source.baseUrl
440444 let uri = this.source.uri
@@ -458,7 +462,6 @@ export struct RNCWebView {
458462 if (!this.hasRegisterJavaScriptProxy) {
459463 this.registerPostMessage()
460464 }
461- this.ignoreSilentHardwareSwitchMethods(this.descriptorWrapper.props.ignoreSilentHardwareSwitch)
462465 })
463466 .onAlert((event) => this.onJavascriptAlert(event))
464467 .onConfirm((event) => this.onJavascriptConfirm(event))
0 commit comments