#鸿蒙学习大百科#如何向RichEditor中添加SymbolSpan?

如何向RichEditor中添加SymbolSpan?

HarmonyOS
2024-10-26 09:31:10
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
自封的不算
@Entry
@Component
struct Index {
  my_builder: CustomBuilder|undefined = undefined;
  controller: RichEditorController = new RichEditorController();
  options: RichEditorOptions = { controller: this.controller };
  build() {
    Column() {
      RichEditor(this.options)
        .onReady(() => {
          this.controller.addTextSpan('点击按钮在此处添加symbol。', {
            style: {
              fontColor: Color.Black,
              fontSize: 15
            }
          })
        })
        .width(300)
        .height(100)
      Button('addSymbolSpan', {
        buttonStyle: ButtonStyleMode.NORMAL
      })
        .height(30)
        .fontSize(13)
        .onClick(() => {
          this.controller.addSymbolSpan($r("sys.symbol.basketball_fill"), {
            style: {
              fontSize: 30
            }
          })
        })
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Center)

  }
  }
分享
微博
QQ
微信
回复
2024-10-26 16:47:04
相关问题