js 輸入框防抖封裝

項目中輸入框防抖方法封裝,常用;

//數量輸入框防抖
 function debounce(fun, delay) {
     return function(args) {
           let that = this;
           let _args = args;
           clearTimeout(fun.id);
           fun.id = setTimeout(function() {
              fun.call(that, _args)
           }, delay)
      }
 }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章