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
函数节流:是确保函数特定的时间内至多执行一次。 函数防抖:是函数在特定的时间内不再被调用后又重复执行。
let timer = null; function fun(){ console.log('onresize') } function throttle(method){ return function(){ if(timer !== null){ clearTimeout(timer); } timer = setTimeout(fn,500); } } window.onresize = ()=>throttle(fun)
// 函数节流 var canRun = true; document.getElementById("throttle").onscroll = function(){ if(!canRun){ return } canRun = false setTimeout( function () { console.log("函数节流") canRun = true }, 500) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
他们都是可以防止一个函数被无意义的高频率调用
函数防抖
函数节流
The text was updated successfully, but these errors were encountered: