使用两次单击模拟双击方法

 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   问题下面的回答

posted @ 2021-11-15 11:58  伊人兮明眸秋水  阅读(67)  评论(0编辑  收藏  举报