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

复制代码
 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 @   伊人兮明眸秋水  阅读(71)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示