1.简单防抖处理,一秒内点击一次vartimer=null;$('.coupon').click(function(){if(timer){return;}timer=true;setTimeout(function(){timer=false;},1000);...})2.向服务器请求数据点击按钮向后台请求数据优化点:varrunning=false;$('.btn').on('click',function(){if(running){return;}running=true;$.ajax(url,{complete:()=>{running=false;}})});其他一些防抖技巧请参考to:http://blog.csdn.net/crystal6...;https://jinlong.github.io/201...3。封装的简单防抖动态函数//debounce函数fn要执行的函数,超时间隔毫秒functiondebounce(fn,timeout){letlast=null;returnfunction(){if(last){返回last.result;}setTimeout(()=>{last=null;},超时||1000);constresult=fn.apply(this,arguments);最后={结果};返回结果;};}//调用btn.addEventListener('click',debounce(function(){...},1000));4.现成的工具库Loadashhttp://www.css88.com/doc/loda...防抖:_.debounce节流:_。风门
