var btnn = document.querySelector('.btnn') btnn.addEventListener('click',debounce(testaa,1000,'11','22'),false) function debounce(fn, wait,...arg) { let t = null; return function () { if (t) { clearTimeout(t); } t = setTimeout(() => { fn.call(this, ...arg); // 绑定上面的 this }, wait) } } function testaa(...arg) { console.log('aaaa',...arg) }
<!-- <input type="" class="aa"> --> <button class="btnn">aaa</button>