参考demo:import inputMethod from '@ohos.inputMethod'; @Entry @Component struct Index { @State message: string = 'Hello World'; build() { Row() { Column() { TextInput() .backgroundColor(Color.Pink) Button('拉起软键盘').onClick(()=>{ inputMethod.getController().showTextInput() }) .backgroundColor(Color.Green) Button('隐藏软键盘').onClick(()=>{ inputMethod.getController().hideTextInput() }) .backgroundColor(Color.Orange) } .width('100%') .height('100%') } .height('100%') } }
参考demo: