HarmonyOS 一段文字显示不同的颜色字体?

一段文字显示不同的颜色字体,以下是我找到的方法,

请问一下,是否有其他方法可以实现

Text() {
  ForEach(this.titleHighlight, (item: HighlightedText) => {
    if (item.value && item.isHighlightText) {
      Span(item.value)
        .fontColor($r('app.color.theme_color'))
        .fontSize(12)
    } else if (item.value && !item.isHighlightText) {
      Span(item.value)
        .fontColor($r('app.color.common_color_text_desc'))
        .fontSize(12)
    }
  })
}
阅读 572
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进