HarmonyOS 鸿蒙Next web加载备案号地址展示为白屏

HarmonyOS 鸿蒙Next web加载备案号地址展示为白屏
我们项目中用到了web加载备案号地址,但展示时为白屏,想请问下是什么原因,代码如下:

@Entry
@Component
struct BrowerPage {
pageTitle: string = ""
url: string = ""
controller: web_webview.WebviewController = new web_webview.WebviewController();

aboutToAppear() {
YdLogger.debug(JSONUtil.beanToJsonStr(router.getParams()))

this.pageTitle = ""
this.url = "xxx"
}

build() {
Column() {
YdCustomNavigation({ mTitle: this.pageTitle })
Column(){
Web({ src: this.url, controller: this.controller})
.javaScriptAccess(true)
.fileAccess(true)
.domStorageAccess(true)
.geolocationAccess(true)
.imageAccess(true)
.cacheMode(CacheMode.None)
.backgroundColor($r('app.color.white'))
.height(CommonConstants.YD_FULL_WITH)
.width(CommonConstants.YD_FULL_HEIGHT)

}
.layoutWeight(1)
.width(CommonConstants.YD_FULL_HEIGHT)
}
}
}

更多关于HarmonyOS 鸿蒙Next web加载备案号地址展示为白屏的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复
```

.onSslErrorEventReceive((e) => {

          e.handler.handleConfirm()

        })

```

具体参考链接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5#onsslerroreventreceive9

咱们给web组件加上以下属性,然后卸载测试真机上的app重新运行项目安装下看看:

```

.cacheMode(CacheMode.Online)

        .mixedMode(MixedMode.All)

```

更多关于HarmonyOS 鸿蒙Next web加载备案号地址展示为白屏的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


针对HarmonyOS 鸿蒙Next web加载备案号地址展示为白屏的问题,以下是一些可能的原因及解决方案:

  1. 网址内容问题:若备案号地址中含有特殊字符(如“#”),可能导致解析错误。建议对这类字符进行转义处理(如将“#”转为“%23”),或直接对Web内容进行Base64编码后再加载。
  2. 系统兼容问题:检查备案号地址对应网页的HTML、CSS、JavaScript等代码,确保它们与鸿蒙系统兼容。
  3. Webview配置问题:确保Webview组件已正确设置相关权限和属性,如允许加载混合内容、开启数据库存储API权限等。同时,检查是否已设置MixedMode为MixedMode.All,以允许加载HTTP协议的内容。
  4. 网络权限问题:检查应用的manifest文件,确保已正确配置网络权限ohos.permission.INTERNET,允许应用进行网络请求。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部