使用两次单击模拟双击方法
1 export default {
2 data() {
3 return {
4 index: 0,
5 start_time: 0,
6 end_time: 0
7 };
8 },
9 methods: {
10 fndbClick() {
11 this.index = this.index == 0 ? 1 : this.index + 1;
12 if (this.index == 1) {
13 this.start_time = new Date().getTime();
14 setTimeout(()=>{
15 this.index = this.start_time = this.end_time = 0;
16 },200)
17 } else if (this.index == 2) {
18 this.end_time = new Date().getTime();
19 if (this.end_time - this.start_time < 300) {
20 uni.showToast({
21 title: '双击了屏幕',
22 icon: 'none'
23 })
24 }
25 this.index = this.start_time = this.end_time = 0;
26 }
27 }
28 }
29 };
30 </script>
原文:https://ask.dcloud.net.cn/question/81152 问题下面的回答
忍一时,越想越气;
退一步,哎呦我去!