<template>
<view>
<button @touchend="dbclick">测测测</button>
<button type="default" @click="db">试一试</button>
<button type="default" @click="d">测试</button>
</view>
</template>
<script>
export default {
data() {
return {
touchNum: 0,
time: [],
index: 0,
start_time: 0,
end_time: 0
}
},
methods: {
dbclick() {
this.touchNum++
setTimeout(() => {
if (this.touchNum == 1) {
console.log('单击')
}
if (this.touchNum >= 2) {
console.log('双击')
}
this.touchNum = 0
}, 250)
},
/// 双击
db(e) {
this.time.push(e.timeStamp)
var t = this.time[this.time.length - 1] - this.time[this.time.length - 2]
console.log(this.time[this.time.length - 1] - this.time[this.time.length - 2])
if (t < 1000) {
uni-app双击事件的实现
最新推荐文章于 2024-08-05 14:24:00 发布
本文介绍了在uni-app中如何实现双击事件,通过示例代码详细讲解了配置与使用过程,适用于希望提升移动端应用交互体验的开发者。
摘要由CSDN通过智能技术生成