1 个回答

可以尝试使用如下代码:

@Entry
@Component
struct relative {
  build() {
    Column() {
      Row() {
        Image('')
          .height(100)
          .width(100)
          .backgroundColor(0xDCDCDC)
        Column() {
          Row() {
            Text('title123123123123123123123123312')
              .fontSize(14)
              .textOverflow({ overflow: TextOverflow.Ellipsis })
              .maxLines(1)
              .layoutWeight(1)
              .margin({ left: 10 })
              .id('title')

            Text('time123213')
              .fontSize(12)
              .id('time')

            Image('')
              .height(20)
              .width(20)
              .id('image')
              .backgroundColor(0xDCDCDC)
          }
        }.layoutWeight(1)
        .height(100)
        .justifyContent(FlexAlign.Start)
      }
    }.width("100%").height("100%")
  }
}

这里的截断机制是把后面所有的数字识别为是一个字符,所以全部截断了,可以设置属性.wordBreak(WordBreak.BREAK\_ALL)来解决该问题

参考链接

MeasureOptions

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