1、安装
yarn add lodash @types/lodash
2、引入
import { debounce } from 'lodash';
3、组件中使用
import { SyntheticeEvent } from 'react'
const fn = (value: string) => {
console.log('调一次接口', value);
}
<Input
onChange={debounce((e: SyntheticeEvent) => {
fn(e.target.value)
}, 1000)}
/>