Web组件加载部分网页中使用了文档对象模型存储接口(DOM Storage API),默认未开启导致网页加载出错。需要设置Web组件domStorageAccess属性为true开启权限。参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5\#domstorageaccess参考代码:import { webview } from '@kit.ArkWeb'; @Entry @Component struct Index { @State message: string = 'Hello World'; @State url: string = "xxx" private controller: webview.WebviewController = new webview.WebviewController(); build() { RelativeContainer() { Web({ src: this.url, controller: this.controller, }) .domStorageAccess(true) } .height('100%') .width('100%') } }
Web组件加载部分网页中使用了文档对象模型存储接口(DOM Storage API),默认未开启导致网页加载出错。
需要设置Web组件domStorageAccess属性为true开启权限。
参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-web-V5\#domstorageaccess
参考代码: