第一种
<button @click=“a” @dblclick=“b”>点击
methods: {
a() {
this.flag = true
setTimeout(() => {
if (this.flag) {
console.log(1);
}
}, 300);
},
b() {
this.flag = false
console.log(5);
}
}
第二种
<button @click=“a” @dblclick=“b”>点击
methods: {
a() {
clearTimeout(timer)
timer = setTimeout(() => {
console.log(1);
}, 300);
},
b() {
console.log(5);
clearTimeout(timer)
}
}