Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the throttled function. Subsequent calls to the throttled function return the result of the last func invocation.
建立一個每wait毫秒最多隻調用一次的函數。throttling函數帶有一個取消方法來取消延遲的func調用,還有一個刷新方法來當即調用它們。提供選項,以指示是否應該在等待超時的前邊緣和/或後邊緣調用func。使用提供給throttling函數的最後一個參數調用func。對throttling函數的後續調用返回上次func調用的結果。react
react裏面防抖ide
handleChange = (function(){
let func = lodash.throttle(function(e){
console.log(e.target.value);
}, 2000)
return function(e){
e.persist();
func(e);
}
})()函數