HarmonyOS webview加载网页,该如何配置?

隐私政策页面,现在的问题是:

1、左上角切换版本字体太小。

2、行间距不对。

阅读 563
1 个回答
import { webview } from '@kit.ArkWeb';

@Entry
@Component
struct WebComponent {
  controller: webview.WebviewController = new webview.WebviewController();
  build() {
    Column() {
      Web({ src: $rawfile('privacyPolicy.html'), controller: this.controller })
        .onControllerAttached(() => {
          this.controller.setCustomUserAgent('Mozilla/5.0 (Linux; xxx; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) xxx/99.0.4844.88 HuaweiBrowser/12.0.4.1 Mobile Safari/537.36')
        })
        .domStorageAccess(true)//设置是否开启文档对象模型存储接口(DOM Storage API)权限,默认未开启。
        .databaseAccess(true)//开启数据库存储权限
        .imageAccess(true)
        .onlineImageAccess(true)
        .cacheMode(CacheMode.None)
        .fileAccess(true)
        .height('100%')
    }
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进