我只是按照react-native: hide keyboard
链接的回答但是键盘在几分之一秒内闪烁然后就会消失。有没有办法完全避开键盘。
答案 0 :(得分:2)
This帮助了我:
import { Keyboard } from 'react-native'
// Hide that keyboard!
Keyboard.dismiss();
答案 1 :(得分:1)
正确的方法是使用TouchableWithoutFeedback关闭View并调用Keyboard.dismiss()
import {Keyboard} from 'react-native'
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={styles.container}>
<TextInput keyboardType='numeric'/>
</View>
</TouchableWithoutFeedback>