封装代码

    1. function tottle(fn,delay=500){
    2. let timer= null;
    3. return function(){
    4. if(timer){
    5. return
    6. }
    7. timer = setTimeOut(()=>{
    8. fn.call(this);
    9. timer = null;
    10. },delay)
    11. }
    12. }