Browse Source

多次点击公共方法

Jyt
jyt 3 years ago
parent
commit
209313856b
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      utils/common.js

+ 25
- 0
utils/common.js View File

@@ -0,0 +1,25 @@
// 防止处理多次点击
function noMultipleClicks(methods, info) {
// methods是点击后需要执行的函数, info是函数需要传的参数
let that = this;
if (that.noClick) {
// 第一次点击
console.log(methods)
that.noClick= false;
if((info && info !== '') || info ==0) {
// info是执行函数需要传的参数
methods(info);
} else {
methods();
}
setTimeout(()=> {
that.noClick= true;
}, 2000)
} else {
// 这里是重复点击的判断
}
}
//导出
export default {
noMultipleClicks, // 禁止多次点击
}

Loading…
Cancel
Save