Web({
src: this.url,
controller: this.controller,
renderMode: RenderMode.SYNC_RENDER
})
.darkMode(WebDarkMode.Off)
.forceDarkAccess(false)
.defaultFontSize(20)
.zoomAccess(false)
.javaScriptAccess(true)
.domStorageAccess(true)
.onPageVisible(() => {
this.showTitle = !this.controller.accessBackward()
})
.onPageEnd(() => {
this.isWebShowed = true;
})
.layoutMode(WebLayoutMode.FIT_CONTENT)
.nestedScroll({
scrollForward: NestedScrollMode.SELF_FIRST,
scrollBackward: NestedScrollMode.PARENT_FIRST,
})
.onControllerAttached(() => {
this.controller.loadData(this.content, 'text/html', 'UTF-8')
})
所调用的this.content在真机测试上内容显示不全,数据请求数据是正常对的。
不建议使用loaddata加载整个页面,loaddata方法只用于显示一些页面片段。loaddata不支持换行和复杂的JavaScript,参数data存在长度大小限制,加载整个页面应采用文档中提供的本地页面加载或者远程页面加载的方式。加载本地或网页,请采用loadUrl方式。
参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/cta-loading-a-page-using-a-web-component-V5\#%E5%8A%A0%E8%BD%BD%E6%9C%AC%E5%9C%B0%E9%A1%B5%E9%9D%A2