我在react-native-paper中使用了两个径向按钮。我将按钮本身和旁边的文本都放在一个onPress函数下,然而,只有当我按下文本时,该函数才会执行,而不是当我按下按钮时。当我按下按钮时,它会高亮显示,并显示它被按下了,但没有执行onPress。
<View style={[s.profile_gender_row]}>
<Text onPress={() => {this.onDataChange('gender', 'F')}}>Female</Text> // this works just fine
<RadioButton
value="F"
status={this.props.gender === 'F' ? 'checked' : 'unchecked'}
onPress={() => {this.onDataChange('gender', 'F')}} // this does not work
/>
</View>
<View style={[s.profile_gender_row]}>
<Text onPress={() => {this.onDataChange('gender', 'M')}}>Male</Text>
<RadioButton
value="M"
status={this.props.gender === 'M' ? 'checked' : 'unchecked'}
onPress={() => {this.onDataChange('gender', 'M')}}
/>
</View>没有任何错误消息,我只是被它不能执行的原因难住了。
发布于 2019-10-22 08:27:08
不幸的是,这听起来像是2.16.0版的bug,目前是最新版本。它应该在3.xx中得到修复,这样你就可以升级到3.0.0-alpha.8进行修复。
https://stackoverflow.com/questions/58209533
复制相似问题