HarmonyOS 鸿蒙Next 方舟Web加载页面空白

HarmonyOS 鸿蒙Next 方舟Web加载页面空白 安卓 web组件,iOS web组件都可以正常加载http://weixintest.ubssdic.com/app-h5/activitymodule/activitymodule.html#/celebration这个页面,但使用ArkWeb加载的时候异常,显示空白页面

3 回复

访问在线网页时需添加网络权限:ohos.permission.INTERNET

请问您有没有配置ohos.permission.INTERNET网络访问权限

若是没有请在module.json5中设置requestPermissions属性值

{
  "module": {
    "requestPermissions": [
      {
        "name": "ohos.permission.INTERNET"
      }
    ]
  }
}

若是网络访问权限已设置,加载页面还是未显示,检查domStorageAccess属性是否设置为true。  

参考代码:

```javascript
import web_webview from '[@ohos](/user/ohos).web.webview'

[@Entry](/user/Entry)
[@Component](/user/Component)
struct WebComponent {

  controller: web_webview.WebviewController = new web_webview.WebviewController();

  build() {
    Column() {
      Web({
        src: 'http://weixintest.ubssdic.com/app-h5/activitymodule/activitymodule.html#/celebration',
        controller: this.controller
      })
      .domStorageAccess(true)
    }
  }
}

更多关于HarmonyOS 鸿蒙Next 方舟Web加载页面空白的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


Web({ src: "http://weixintest.ubssdic.com/app-h5/activitymodule/activitymodule.html#/celebration", controller: new web_webview.WebviewController() })

    .domStorageAccess(true)

我试过了可以显示没问题,记得加上 .domStorageAccess(true)

针对“HarmonyOS 鸿蒙Next 方舟Web加载页面空白”的问题,这通常指的是在鸿蒙系统的方舟运行时(Ark Runtime)环境中,Web内容无法正常渲染,只显示空白页面。可能的原因及处理方式如下:

  1. 资源路径问题:检查Web资源的路径是否正确,确保所有需要的文件(如HTML、CSS、JavaScript等)都已正确加载且路径无误。

  2. 权限配置:确认应用是否有足够的权限去访问和加载Web资源。在鸿蒙系统中,权限管理较为严格,需要确保应用已申请并获得了必要的权限。

  3. 方舟运行时兼容性问题:检查所使用的方舟运行时版本是否支持当前加载的Web内容。有时,Web内容可能依赖于特定版本的浏览器特性或API,而这些在方舟运行时中可能未完全实现或存在兼容性问题。

  4. 代码错误:检查Web内容的代码,确保没有语法错误或逻辑错误导致页面无法正确渲染。

  5. 系统更新:尝试将鸿蒙系统更新到最新版本,以获取最新的方舟运行时支持和修复可能存在的bug。

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

回到顶部