react函數式組件中使用lodash的debounce

react函數式組件中使用lodash的debounce

阿凡農
2020.09.22 21:18:20字數 44閱讀 3,769

import _ from 'lodash'

<Input style={{ marginBottom: 16 }} maxLength={25} onChange={userChange} />

const userChange = (e: any) => {
callAjax(e.target.value)
}

const getMember = (value: any) => {
fetchMember(value); // 最終的獲取ajax數據的方法
}

const callAjax = _.debounce(getMember, 300)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章