我使用的HarmonyOS NEXT SDK是API 15,发现在RichEditor中输入纯文本,getSpan会返回文本数组,例如 "Hello World!你好,世界!" 之类的纯文本内容,请问为什么会有这种情况,之前的版本没发现呢?
controller: RichEditorController = new RichEditorController();
options: RichEditorOptions = { controller: this.controller }
controller1: RichEditorController = new RichEditorController();
options1: RichEditorOptions = { controller: this.controller1 }
// 创建两个富文本组件
RichEditor(this.options)
.onReady(() => {
this.controller.addTextSpan('点击按钮获取此处span信息。', {
style: {
fontColor: Color.Black,
fontSize: 15
}
})
})
.width(300)
.height(50)
Text('查看getSpans返回值:').fontSize(10).fontColor(Color.Gray).width(300)
RichEditor(this.options1)
.width(300)
.height(50)
Button('getSpans', {
buttonStyle: ButtonStyleMode.NORMAL
})
.height(30)
.fontSize(13)
.onClick(() => {
this.controller1.addTextSpan(JSON.stringify(this.controller.getSpans()), {
style: {
fontColor: Color.Gray,
fontSize: 10
}
})
})
自定义标签:HarmonyOS NEXT;OpenHarmony;ArkUI;RichEditor;RichEditorController;文本