HarmonyOS RichText 展示问题?

如题:HarmonyOS RichText 展示问题?

阅读 556
1 个回答

问题场景

build() {
  Column() {
    Row({space:10}) {
      Column() {
        RichText(  this.item.title ?? "" )
          .width("100%")
          .height(80)

        Text(this.item.desc ?? "")
          .fontSize(12)
          .fontColor(0x9e9e9e)

      }
      .margin({left: 10})
      .layoutWeight(1)
      .alignItems(HorizontalAlign.Start)
      .justifyContent(FlexAlign.SpaceAround)
      .height('100%')

      Blank()

      Image(this.item.banner ?? "")
        .width(this.picWidth)
        .objectFit(ImageFit.Fill)
        .height( this.picWidth * 0.75 )
        .borderRadius(4)
    }
    .padding({left:20,right:20})
    .height( 20 + this.picWidth * 0.75 )
    .width("100%")

  }
}

RichText 传入内容, 显示的文字太小,RichText 组件还会滑动,如何能正常展示

RichText字体大小可以通过style设置 例如<p style="font-size: 35px;text-align: center;font-weight: bold; color: rgb(24,78,228)"\>字体大小35px,行高45px</p\>移动设备的视口默认值大小为980px,默认值可以确保大部分网页在移动设备下可以正常浏览。如果RichText组件宽度低于这个值,content内部的HTML则可能会产生一个可以滑动的页面被RichText组件包裹。如果想替换默认值,可以在content中添加以下标签

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-richtext-V5\#ZH-CN\_TOPIC\_0000001884757834

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进