HarmonyOS 使用Webview加载huawei首页出现操作条,且宽度不能自适应?

如题:HarmonyOS 使用Webview加载huawei首页出现操作条,且宽度不能自适应?

阅读 566
1 个回答
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
  controller: web_webview.WebviewController = new web_webview.WebviewController();
  @State userAgent: string =
    'Mozilla/5.0 (Phone; OpenHarmony 4.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile automobile/792'
  aboutToAppear() {
    web_webview.WebviewController.setWebDebuggingAccess(true);
  }
  build() {
    Column() {
      Web({ src: "", controller: this.controller })
        .javaScriptAccess(true)
        .domStorageAccess(true)
        .width("100%")
        .height("100%")
        .onControllerAttached(() => {
          this.controller.setCustomUserAgent(this.userAgent);
          this.controller.loadUrl("www.huawei.com")
        })
    }
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题