// 防止快速连续点击,节流函数
function throttle(fun, delay) {
let oadDate = Date.now();
return function() {
let _this = this;
let args = arguments;
let newDate = Date.now();
if(newDate-oadDate > delay) {
fun.apply(_this, args);
oadDate = Date.now();
}
}
}
Call method: click: throttle (function {// click operation}, 1000), 1000 set time 1s
If it is useful to you, pay attention to the blogger's applet, log in to give support, and any open source and useful source code will be uploaded to the applet in the future