建议先使用RichEditor来开发。RichEditor可以由开发者控制点击发送以后是否收起键盘。如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-richeditor-V5\#submitcallback12使用RichEditor,参考demo:@Entry @Component struct Index { controller: RichEditorController = new RichEditorController(); options: RichEditorOptions = { controller: this.controller }; build() { Row() { Column() { RichEditor(this.options) .onReady(() => { this.controller.addTextSpan("@地球 ", { style: { fontColor: '#007dff', fontSize: 16 } }) }) .onIMEInputComplete((value: RichEditorTextSpanResult) => { console.log(`reulst ==> ${JSON.stringify(value)}`); }) .enterKeyType(EnterKeyType.Send) .borderWidth(1) .borderColor(Color.White) .backgroundColor(Color.White) .width("100%") .onSubmit((enterKey: EnterKeyType, event: SubmitEvent) => { // 调用时保持编辑态。 event.keepEditableState(); }) } .width("100%") } .height("100%") .backgroundColor('#ffeeeeee') } }
建议先使用RichEditor来开发。RichEditor可以由开发者控制点击发送以后是否收起键盘。如下:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-richeditor-V5\#submitcallback12
使用RichEditor,参考demo: