#鸿蒙学习大百科#如何通过属性字符串实现文字中局部删除线效果?

如何通过属性字符串实现文字中局部删除线效果?

HarmonyOS
2024-10-26 09:49:01
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
海底捞天王
@Entry
@Component
struct Index {
  mutableStyledString: MutableStyledString = new MutableStyledString("运动35分钟", [
    {
      start: 0,
      length: 3,
      styledKey: StyledStringKey.DECORATION,
      styledValue: new DecorationStyle({type: TextDecorationType.LineThrough, color: Color.Red})
    }
  ]);
  controller: TextController = new TextController();

  async onPageShow() {
    this.controller.setStyledString(this.mutableStyledString)
  }

  build() {
    Column() {
      // 显示属性字符串
      Text(undefined, { controller: this.controller })
    }
    .width('100%')
  }
}
  • 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-10-26 16:33:57
相关问题
#鸿蒙学习大百科#如何实现ui优化?
980浏览 • 1回复 待解决