问题这是原生版函数节流方法:匿名函数(注:returnfunction(){}在methods中不能执行)请问,怎么将其改成vue版呢?由于在滚动和中文搜索框中十分常用,请教贴代码:created(){window.addEventListener('scroll',()=>{this.debounce()(this._log,1000);}},methods:{debounce(fn,idle){letsetTm;console.log('debounce')if(!idle||idle<=0)returnfn;returnfunction(){clearTimeout(setTm);setTm=setTimeout(fn.bind(this,...arguments),idle);}},_log(){console.log('_log')},}
慕森卡
慕桂英3389331
相关分类