【发布时间】:2019-11-28 06:21:25
【问题描述】:
<TouchableOpacity
onPressIn={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressIn') }}
onPressOut={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressOut') }}
onPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPress') }}
onLongPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onLongPress') }}>
<Image
source={{ uri: item.images.medium }}
style={styles.item_image}
/>
</TouchableOpacity>
console.log
1574921523 "onPressIn"
1574921523 "onLongPress"
1574921523 "onPressOut"
为什么没有触发onPress,却触发了onLongPress?
https://facebook.github.io/react-native/docs/touchablewithoutfeedback#onlongpress
【问题讨论】:
-
您可以尝试评论 onLongPress 或 onPressIn 或 onPressOut。可能会将控制权传递给其他回调。
-
但我不知道为什么会这样?这不合理吗?
-
为什么需要所有回调?仅供参考:github.com/facebook/react-native/issues/15088
-
delayLongPress={1500}
-
嘿@ebyteebyte你在哪里检查onpress和onlongpress ...在模拟器中???
标签: react-native react-native-android touchableopacity