/*
* 函数节流
*/
function throttle(fn, wait) {
let last = 0
let dur = wait || 400
return function() {
let self = this
const current_time = new Date()
if(current_time - last > dur) {
fn.apply(self, arguments)
last =+ new Date()
}
}
}
/*
* 函数防抖
*/
function throttle(fn, wait) {
let timer
let dur = wait || 400
return function() {
clearTimeout(timer)
let self = this
let args = arguments
timer = setTimeout(function() {
fn.apply(self, args)
}, dur)
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。