1.准备好防抖函数 function debounce(func, wait) { let timeout; return function (...args) { if (timeout) clearTimeout(timeout); let isTime = !timeout; timeout = setTimeout(function () { timeout = null; }, wait); if (isTime) func.apply(this, args); }; } 2.html节点 <input type="button" @click="toDoSth" /> 3.methods中调用 methods: { toDoSth: debounce( function () { this.log(); }, 500, true ), log() { console.log(12313); } },
标签:function,vue,log,中防抖,args,timeout,写法,methods From: https://www.cnblogs.com/web-aqin/p/16707902.html