<template>
<view>
<u-button @click="handleButtonClick">双击我</u-button>
</view>
</template>
<script>
export default {
methods: {
handleButtonClick(event) {
// 获取当前时间戳
const currentTime = new Date().getTime();
// 判断上一次点击时间与当前时间的差值
if (this.lastClickTime && currentTime - this.lastClickTime < 500) {
// 是双击事件
console.log('双击事件');
} else {
// 不是双击事件,更新上一次点击时间
this.lastClickTime = currentTime;
}
},
},
};
</script>
实现双击事件
最新推荐文章于 2024-09-13 23:32:49 发布