diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets index 4a220839ab4bb5b753757ee828c8de1b49423ded..a9d46b2045074447f7097e9bd561523d886248e7 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/InAppWebViewManager.ets @@ -39,6 +39,8 @@ export class InAppWebViewManager extends ChannelDelegateImpl { public windowAutoincrementId: number = 0 + public debuggingEnabled = false; + constructor(plugin: InAppWebViewFlutterPlugin) { super(new MethodChannel(plugin.messenger!, METHOD_CHANNEL_NAME)); this.plugin = plugin @@ -88,8 +90,8 @@ export class InAppWebViewManager extends ChannelDelegateImpl { break; case "setWebContentsDebuggingEnabled": { - let debuggingEnabled: boolean = call.argument("debuggingEnabled") as boolean; - web_webview.WebviewController.setWebDebuggingAccess(debuggingEnabled) + this.debuggingEnabled = call.argument("debuggingEnabled") as boolean; + web_webview.WebviewController.setWebDebuggingAccess(this.debuggingEnabled) } result.success(true); break; diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index 38401886bc871dff77989edf50bb81da68926abd..ba6fc497408032efd6ab18ac0689d69d4221df08 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -1014,6 +1014,9 @@ export default class InAppWebView implements InAppWebViewInterface { }) } + isDebuggingEnabled() { + return this.plugin.inAppWebViewManager!.debuggingEnabled + } disposeWebMessageChannels(): void { for (let webMessageChannel of this.webMessageChannels.values()) { diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets index 449b13b190bc7fb96c4c402c83261947eb7aee27..752a115e98b16721f1b35fc5b8949a65c646f742 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/OhosWebView.ets @@ -48,6 +48,9 @@ export struct OhosWebView { context.eventHub.on(EventConstant.EVENT_UPDATE_CACHEENABLE, (enable : boolean) => { this.cacheEnabled = enable; }); + + //不知道为什么这个静态方法必须要在aboutToAppear里面设置才能生效? + web_webview.WebviewController.setWebDebuggingAccess(this.inAppWebView!.isDebuggingEnabled()); } aboutToDisappear(): void {