缺点是不能完全封装
switch=true
execTime:number
throttle(fn,interval){if(new Date().getTime()-this.execTime>interval){this.switch=true}
if(this.switch){fn();
this.switch=false;
this.execTime=new Date().getTime();
}
}
switch=true
execTime:number
throttle(fn,interval){if(new Date().getTime()-this.execTime>interval){this.switch=true}
if(this.switch){fn();
this.switch=false;
this.execTime=new Date().getTime();
}
}