Full Hand original, reproduced please indicate the source:
Let us focus first pit may encounter: in the choice of two main methods of the original default settings and parameters, read this summary you will know how it happens -
throttle API to go from
_.throttle(func, [wait=0], [options={}])
func (Function): function to be throttled.
[Wait = 0] (number): the number of milliseconds needed throttled.
[Options = {}] (Object): Object option.
[Options.leading = true] (boolean): Specifies called before the throttle, the default true.
[Options.trailing = true] (boolean): Specifies the call after throttling, default true.
Throttle Demo go from (Vue wording)
testThrottle: _.throttle(function() { console.log("throttle"); }, 2000, { leading: true, trailing: false })
Performing a pre-set period, the time when the call operation is not less than the execution period of the operation is executed, then the next time a new period.
In short: the end point of time does not change with the click
_.debounce(func, [wait=0], [options={}])
func (Function): anti-shake function to be.
[Wait = 0] (number): number of milliseconds to be delayed.
[Options = {}] (Object): Object option.
[Options.leading = false] (boolean): Specifies the delay before the start of the call, the default false.
[Options.maxWait] (number): set the allowable maximum func delayed.
[Options.trailing = true] (boolean): Specifies the call after the end of the delay, default true.
When you call the action triggered a period of time, before the implementation of the action will be recalculated if they call this action during this time interval time interval.
In short: the end time point will change with the click