【发布时间】:2022-01-09 05:03:39
【问题描述】:
当 onLongPress 被触发时,如何防止 onPress 的函数运行。当前当我松开按钮后长按onPress仍然被触发。
const _handleOnpress =()=>{
console.log('onPressed triggered')
// other task only for onPress event
}
const _handleLongPress =()=>{
console.log('LongPress triggered')
// other task only for onLongPress event
}
return(
<Pressable
onPress={_handleOnpress}
onLongPress={_handleLongPress}
>
<Text>Press me</Text>
</Pressable>
)
【问题讨论】:
-
我认为这个答案可能会对您有所帮助。 stackoverflow.com/a/36309491/13719014
-
我想在按钮长按时禁用onPress功能
标签: javascript reactjs react-native