React Native:如何使 TouchableOpacity 在用户按住时采取特定操作?
React Native: how to make TouchableOpacity take specific action when user holds it down?
在我的 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}
/>
在我的 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}
/>