HarmonyOS 关于webview.WebviewController.setWebDebuggingAccess(true)的调用时机问题

//可正常调试:
aboutToAppear(): void {
  webview.WebviewController.setWebDebuggingAccess(true)
}

//不可调试1:
aboutToAppear(): void {
  bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo) => {
  if (bundleInfo && bundleInfo.appInfo) {
  const debuggingAccess = bundleInfo.appInfo.debug || bundleInfo.appInfo.appProvisionType === 'debug'
  webview.WebviewController.setWebDebuggingAccess(debuggingAccess)
}
})
}

//不可调试2:
export default class EntryAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
    webview.WebviewController.setWebDebuggingAccess(true);
  }
}

什么原因会导致该问题出现

HarmonyOS
2024-12-25 15:50:12
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

setWebDebuggingAccess只能在aboutToAppear中调用,至于不可调试的问题,可以尝试getBundleInfoForSelfSync同步方法获取debug状态,参考文档如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-bundlemanager-V5#bundlemanagergetbundleinfoforselfsync10

分享
微博
QQ
微信
回复
2024-12-25 17:58:28
相关问题
关于HarmonyOS webview中iFrame使用问题
485浏览 • 1回复 待解决
关于WebView报空指针问题
7189浏览 • 1回复 待解决
多个xcompnent调用init时机
432浏览 • 1回复 待解决
process调用时构建异常
470浏览 • 1回复 待解决
HarmonyOS getContext方法时机问题
672浏览 • 1回复 待解决
关于WebView提示没有用户手势问题
10600浏览 • 1回复 待解决
HarmonyOS 动画执行时机问题
449浏览 • 1回复 待解决