请问uniapp 有双击事件的方法吗
今天回复我了吗
- 发布:2019-10-22 14:54
- 更新:2022-11-16 17:55
- 阅读:6873
1***@qq.com - 你可愿与我再并肩
export default {
data() {
return {
index: 0,
start_time: 0,
end_time: 0
};
},
methods: {
fndbClick() {
this.index = this.index == 0 ? 1 : this.index + 1;
if (this.index == 1) {
this.start_time = new Date().getTime();
setTimeout(()=>{
this.index = this.start_time = this.end_time = 0;
},200)
} else if (this.index == 2) {
this.end_time = new Date().getTime();
if (this.end_time - this.start_time < 300) {
uni.showToast({
title: '双击了屏幕',
icon: 'none'
})
}
this.index = this.start_time = this.end_time = 0;
}
}
}
};
</script>
张明明 - 热爱前端
<template>
<view @click="G8Click">狂击</view>
</template>
export default {
data() {
return {
index: 0, //双击
timer: null //双击
};
},
methods: {
G8Click() {
this.index = this.index + 1;
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
if (this.index == 1) {
console.log('单击');
}
if (this.index == 2) {
console.log('双击');
}
if (this.index == 3) {
console.log('三击');
}
if (this.index == 4) {
console.log('四击');
}
console.log(this.index + '击');
this.index = 0;
}, 200);
},
}
};
</script>
今天回复我了吗 (作者)
可以,爱了
2021-01-26 15:41