#鸿蒙学习大百科#如何监听RichEditor组件选中内容时的回调?

如何监听RichEditor组件选中内容时的回调?

HarmonyOS
2024-10-26 09:18:13
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
天涯独一隅
import { JSON } from '@kit.ArkTS';

@Entry
@Component
struct Index {
  controller: RichEditorController = new RichEditorController();
  options: RichEditorOptions = { controller: this.controller };

  build() {
    Column() {
      RichEditor(this.options)
        .onReady(() => {
          this.controller.addTextSpan('选中此处文本,触发onselect回调。', {
            style: {
              fontColor: Color.Black,
              fontSize: 15
            }
          })
        })
        .onSelect((value: RichEditorSelection) => {
          console.log("=====value:"+JSON.stringify(value))
        })
        .width(300)
        .height(50)
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Center)
  }
}
分享
微博
QQ
微信
回复
2024-10-26 17:46:10
相关问题