function throttle(fn, delay){
let timer = null
return function(...args) {
if(timer) return
let _this = this
timer = setTimeout(() => {
fn.apply(_this, args)
timer = null
}, delay)
}
function throttle(fn, delay){
let timer = null
return function(...args) {
if(timer) return
let _this = this
timer = setTimeout(() => {
fn.apply(_this, args)
timer = null
}, delay)
}
本文标题:节流函数
本文链接:https://www.haomeiwen.com/subject/lkusixtx.html
网友评论