请参考以下示例:import { inputMethod } from '@kit.IMEKit'; @Entry @Component struct LeftRightTest { @State a:boolean =true; controller: TextInputController = new TextInputController() build() { Column() { TextInput({placeholder: '请输入内容'}) .backgroundColor(Color.Orange) .onTouch(()=>{ this.a=true; }) Button('点我') TextInput({placeholder: '请输入内容'}) .backgroundColor(Color.Orange) .onTouch(()=>{ this.a=true; }) } .height('100%') .width('100%') .onTouch(() => { if (this.a!=true) { // 收起键盘 let inputMethodController = inputMethod.getController(); inputMethodController.stopInputSession() } this.a=false }) } }
请参考以下示例: