防抖(debounce) 所谓防抖,就是指触发事件后在 n 秒内函数只能执行一次,如果在 n 秒内又触发了事件,则会重新计算函数执行时间. 节流(throttle) 所谓节流,就是指连续触发事件但是在 n 秒中只执行一次函数.节流会稀释函数的执行频率. 就相当于,一个水龙头在滴水,可能一次性会滴很多滴,但是我们只希望它每隔 500ms 滴一滴水,保持这个频率.即我们希望函数在以一个可以接受的频率重复调用. vue 封装utils.js const debounce = (func, time,
使用js动态移动滚动条至底部. var currentPosition,timer; function GoBottom(){ timer=setInterval("runToBottom()",50); } function runToBottom(){ currentPosition=document.documentElement.scrollTop || document.body.scrollTop; currentPosition+=30; if(curren