throttle(method, delay, duration) {
let timer = null
let begin = new Date().getTime()
return function() {
let cur = new Date().getTime()
clearTimeout(timer)
if(cur - begin >= duration) {
method()
begin = cur
} else {
timer = setTimeout(function () {
method()
}, delay)
}
}
},
网友评论