我在我的Reactjs应用程序中使用React-date-picker。当我在移动设备上测试日期选择器选项时,键盘也会出现。我尝试了一些。但这不能解决我的问题。
<DatePicker onChange={this.bidHandleChangeStart}
value={this.state.startDate} name="startDate" maxDate={new Date()} customInput={<CustomInput />} />
const CustomInput = React.forwardRef((props,ref) => {
return (
<input
readOnly={true}
/>
)
})
您可以使用keyboard
模块解决问题。
实施例
import {Keyboard} from 'react-native';
...
componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
this._keyboardDidShow,
);
}
componentWillUnmount() {
this.keyboardDidShowListener.remove();
}
_keyboardDidShow() {
alert('Keyboard Shown');
Keyboard.dismiss()
}
尝试在获得焦点时强制模糊。我不知道React,但类似:-
onFocus={this.blur()}