react-native中有键盘事件,但是如何在我的Web应用程序中使用它们。我创建了一个搜索,仅在隐藏键盘时才想显示搜索,以防键盘在视图中,用户可以通过键盘上的搜索按钮进行搜索。
componentWillMount () {
this.keyboardWillShowSub = Keyboard.addListener('keyboardDidShow', this.keyboardDidShow.bind(this));
this.keyboardWillHideSub = Keyboard.addListener('keyboardDidHide', this.keyboardDidHide.bind(this));
console.log(this.keyboardWillHideSub);
}
componentWillUnmount() {
this.keyboardWillShowSub.remove();
this.keyboardWillHideSub.remove();
}
keyboardDidHide(){
this.setState({keyboardUp: false});
}
keyboardDidShow(){
this.setState({keyboardUp: true});
}
这是我的代码,我使用了react-native-web软件包,但不起作用。