zhouwenxuan
2023-11-15 f5d67b69142c78be1ee996f53b6bb8e4c954761c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 防止处理多次点击
function noMoreClicks(methods, info) {
    // methods是需要点击后需要执行的函数, info是点击需要传的参数
    let that = this;
    if (that.noClick) {
        console.log("点击")
        // 第一次点击
        that.noClick= false;
        if(info && info !== '') {
            // info是执行函数需要传的参数
            methods(info);
        } else {
            methods();
        }
        setTimeout(()=> {
            that.noClick= true;
        }, 2000)//时间可以自己定义
    } else {
        // 这里是重复点击的判断
        uni.showToast({
            title: '请稍后点击',
            icon: 'error',
            duration: 1000
        })
    }
}
//导出
export default {
    noMoreClicks,//禁止多次点击
}