input 防抖

419 阅读1分钟

const debounce = (fn, wait) => { let timeout = null; return function(input) { input.persist(); if (timeout !== null) clearTimeout(timeout); timeout = setTimeout(fn, wait, input); }; };

const handelChange = e => { console.log(e.target.value); };

<Input onChange={debounce(handelChange, 1000)} placeholder="搜索用户" style={{ width: "250px", marginBottom: "15px" }} prefix={}