<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
答案 0 :(得分:0)
在开发过程中,我也面临着与onLongpress和 onPress都无法正常工作,但是当我完成构建后 它按预期运行。
So try to make the build of the app, and it will work fine
希望这会有所帮助。...谢谢:)