在我的 React Native 应用程序中,我有一个 TouchableOpacity
,当我单击它时,它会执行特定操作。但我希望如果用户按住它一秒钟,它会采取不同的操作。有办法做到这一点吗?
最佳答案
记录到文档:https://reactnative.dev/docs/handling-touches
handlerLongClick = () => {
console.log('Button pressed long');
};
handlerClick = () => {
console.log('Button pressed');
};
<TouchableOpacity
onLongPress={this.handlerLongClick}
onPress={this.handlerClick}
/>
关于reactjs - react native : how to make TouchableOpacity take specific action when user holds it down?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61857617/