防抖
1 | export function debounce(fn, delay) { |
节流
1 | export function throttle(fn, delay, cb) { |
注意不要使用箭头函数,不然会导致 this 错乱,因为 call 也无法改变箭头函数 this 指向
1 | export function debounce(fn, delay) { |
1 | export function throttle(fn, delay, cb) { |
注意不要使用箭头函数,不然会导致 this 错乱,因为 call 也无法改变箭头函数 this 指向