HarmonyOS 在使用richText渲染富文本数据时,进入页面内容默认是放大显示的。如果默认到最合适屏幕显示尺寸呢

HarmonyOS
2024-12-25 11:24:41
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

可参考下面代码

updataContent: string = '<html><body><div><span style=\'color:#2d64b3;font-size:14px;\'>@xx </span>可以问吧<p>111</p><p>111</p><p>111</p><p>111</p><p>111</p></div></body>' +
  '<script type=\'text/javascript\'>function watchWindowSize(){ var h = document.body.clientHeight; return h; }</script></html>'

Web({ src: '', controller: this.controller })
  .layoutMode(WebLayoutMode.FIT_CONTENT)
  .onControllerAttached(() => {
    this.controller.loadData(this.updataContent, "text/html", "UTF-8", " ", " ");
  })
  .javaScriptAccess(true)
  .onPageEnd(e => {
    this.controller.runJavaScript(
      'watchWindowSize()',
      (error, result) => {
        let webResult = Number(result)
        this.pageHeight = webResult
        console.info('webResult=' + webResult);
      }
    )
  })
  .nestedScroll({
    scrollForward: NestedScrollMode.SELF_FIRST,
    scrollBackward: NestedScrollMode.SELF_FIRST,
  })
  .width('100%')
  .height(this.pageHeight)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
分享
微博
QQ
微信
回复
2024-12-25 14:10:03
相关问题
HarmonyOS html文本显示问题
2259浏览 • 1回复 待解决
如何把导航默认最底下显示
402221浏览 • 1回复 待解决
HarmonyOS 文本渲染问题
1199浏览 • 1回复 待解决
HarmonyOS 屏幕默认高度咨询
437浏览 • 1回复 待解决
应用如何适配大显示模式
2723浏览 • 1回复 待解决