不论触发函数多少次,函数只在设定条件到达时调用第一次函数设定,函数节流
1 | let throttle = function(fn,intervalTime){ |
不论出发函数多少次,函数只在最后一次调用函数时开始计时,函数防抖
1 | let debounce = function(fn,intervalTime){ |
优化后的开源库版本的throttle函数
1 | let throttle = function(fn,intervalTime){ |
原文:https://www.cnblogs.com/lijianming180/p/12258737.html