js防止页面抖动(按钮,请求等重复提交)

用防抖动来阻止页面的重复提交:    

function debounce(func, wait) {
let timeout
return function () {
clearTimeout(timeout)
timeout = setTimeout(func, wait) //返回计时器 ID
}
}

使用:

       debounce(doSomething, 1000);

猜你喜欢

转载自www.cnblogs.com/chenlongsheng/p/11112334.html
今日推荐