项目经常会遇到用户连续点击按钮或者连续输入内容的情况。可以使用节流和防抖的思想来优化处理//函数防抖Vue.prototype.$debounce=function(fn,delay){lettimer=null;//记录最后一次延迟lettime=delay||200;returnfunction(){让args=arguments;让那个=这个;清除超时(计时器);//清除最后一个延迟timer=setTimeout(function(){fn.apply(that,args)},time);}};例如:this.$debounce(()=>{},3000);//functionThrottleVue.prototype.$throttle=(function(){letlastTime;lettimer;returnfunction(fn,delay){lettime=delay||3000;letnowTime=Date.now();//记录当前函数触发时间if(lastTime&&nowTime-lastTime
