// 节流
function thro(func, wait) {
let timeOut;
return function () {
if (!timeOut) {
timeOut = setTimeout(() => {
func();
timeOut = null;
}, wait);
}
};
}
function handle() {
console.log(Math.random());
}
document.getElementById("button").onclick = thro(handle, 2000);
前端-节流函数
最新推荐文章于 2023-06-07 18:57:19 发布