可以通过showTextInput方法显示软键盘,hideTextInput隐藏软键盘,文档连接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inputmethod-V5\#ZH-CN\_TOPIC\_0000001884918610\_\_hidetextinput10import inputMethod from '@ohos.inputMethod'; @Entry @Component struct Index2 { @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%') } }
可以通过showTextInput方法显示软键盘,hideTextInput隐藏软键盘,文档连接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inputmethod-V5\#ZH-CN\_TOPIC\_0000001884918610\_\_hidetextinput10