如题,该属性/功能默认是没有开启的!!!!
所以需要我们手动开启,否侧加载的H5 SPA大概率功能不正常,因为现在大多数的H5应用都用遇到对象模型存储的功能,对应的接口是
不开启一般会遇到的异常如下,类似“TypeError: Cannot read properties of null (reading ‘getItem’)”的错识
如何开启!示例代码如下:(关建是domStorageAccess(true)这句)
// xxx.ets
import { webview } from '@kit.ArkWeb';
@Entry
@Component
struct WebComponent {
controller: webview.WebviewController = new webview.WebviewController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.domStorageAccess(true)
}
}
}
参考文档:domStorageAccess