|
|
@ -11,15 +11,34 @@ function noMultipleClicks(methods, info) { |
|
|
|
} else { |
|
|
|
methods(); |
|
|
|
} |
|
|
|
setTimeout(()=> { |
|
|
|
let timer = setTimeout(()=> { |
|
|
|
that.noClick= true; |
|
|
|
clearTimeout(timer) |
|
|
|
}, 2000) |
|
|
|
} else { |
|
|
|
// 这里是重复点击的判断
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 节流函数
|
|
|
|
const throttle = (fn, t,_this) => { |
|
|
|
console.log('throttle') |
|
|
|
return ()=> { |
|
|
|
if (!_this.timer) { |
|
|
|
_this.timer = setTimeout(()=>{ |
|
|
|
fn() |
|
|
|
console.log('fn') |
|
|
|
//·清空定时器
|
|
|
|
_this.timer = null |
|
|
|
}, t) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//导出
|
|
|
|
export default { |
|
|
|
noMultipleClicks,//禁止多次点击
|
|
|
|
throttle |
|
|
|
} |
|
|
|