我在 ScrollView 和 KeyboardAvoidingView 中使用 TextInput,但它需要在键盘打开时点击两次才能提交文本。
对于解决方案,我添加了keyboardShouldPersistTaps="always"但它不起作用。
render() {
return (
<View style={{flex: 1}}>
<KeyboardAvoidingView style={{flex:1}}>
<ScrollView keyboardShouldPersistTaps="always"
contentContainerStyle={{
paddingHorizontal: 10,
flexGrow : 1,
justifyContent : 'center',
alignItems:'center'}}>
<View style={{backgroundColor:'green', width:'100%', borderRadius:8, overflow:'hidden'}}>
<TextInput style={{margin:10}}/>
<TouchableOpacity onPress={() => {alert('alert')}}>
<Text>Submit</Text>
</TouchableOpacity>
</View>
</ScrollView>
</KeyboardAvoidingView>
</View>
)
}
如何在单击时触发新闻事件?