Kis*_*ore 5 onblur react-native
<TextInput
ref={ ref => this.mobileNumberRef = ref}
keyboardType='phone-pad'
returnKeyType='done'
onBlur={() => Keyboard.dismiss()}
/>
Run Code Online (Sandbox Code Playgroud)
当触摸到该区域之外时,我想关闭键盘TextInput。但并onBlur()没有被解雇。
有人可以让我知道如何实现这一目标吗?谢谢你!
首先,onBlur当文本输入模糊时调用。但是,如果您想在触摸 TextInput 区域之外时关闭键盘,请使用以下场景
<ScrollView keyboardShouldPersistTaps="handled">
<TextInput
onChangeText={this.onChangeText}
keyboardType="phone-pad"
returnKeyType="done"
/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
或者
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={{ flex: 1, backgroundColor: "#fff" }}>
<TextInput
onChangeText={this.onChangeText}
keyboardType="phone-pad"
returnKeyType="done"
/>
</View>
</TouchableWithoutFeedback>
Run Code Online (Sandbox Code Playgroud)
希望这对您有帮助。如有疑问,请放心。
| 归档时间: |
|
| 查看次数: |
7622 次 |
| 最近记录: |