We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function debounce (func, delay) { let timer return function (...args) { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { func.apply(this, args) }, delay) } }
function throttle(fn, interval) { let flag = true; return funtion(...args) { if (!flag) return; flag = false; setTimeout(() => { fn.apply(this, args); flag = true; }, interval) } }
或者用时间差的方式判断
functionn throttle(fn, interval) { let last = null return function (...args) { let now = Date.now() // 还没到时间 if(now - last < interval) return last = now fn.apply(this, args) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Debounce
Throttle
或者用时间差的方式判断
The text was updated successfully, but these errors were encountered: