我有两个可重叠的可触摸对象。单击重叠区域会使它们同时发射。我只希望触发子onPress事件(即,仅onUpVote / onDownVote函数)。
<TouchableHighlight onPress={onPress} underlayColor={colors.focus}>
<View style={styles.container}>
<AppText>{question.content}</AppText>
<View style={styles.voteContainer}>
<UpVoteButton
voted={voted}
voteCount={question.upVotes}
onPress={onUpVote}
/>
<DownVoteButton
voted={false}
voteCount={question.downVotes}
onPress={onDownVote}
/>
</View>
</View>
</TouchableHighlight>
这就是VoteButton元素
<TouchableWithoutFeedback onPress={onPress}>
<View style={styles.voteContainer}>
<AppText style={styles.voteCount}>{voteCount}</AppText>
<AntDesign
name={voted ? "like1" : "like2"}
style={{
fontSize: 18,
color: defaultStyles.colors.focus,
paddingBottom: 3,
}}
/>
</View>
</TouchableWithoutFeedback>
想法是,如果用户按下拇指向上/向下图标区域,则将处理onDownVote。按下列表项中的其他任何位置,应该会将您带到其他屏幕。