To use the plug-in in the vue project throttle-debounce
, you need to throttle the button (multiple clicks only request once, and the last time is not executed), and then use it throttle
, the code is as follows:
throttle(3000, true, function() {
//...
})
Because I saw that the introduction of throttle is like this, as shown in the figure below:
But using noTrailing to report an error in this way,callback.apply is not a function
so I checked the location of the error:
I found that the parameter format is not throttle(delay, noTrailing, callback, debounceMode)
, but throttle(delay, callback, options)
this options contains noTrailing and debounceMode.
So, modify the code as follows:
throttle(3000, function() {
//...
}, {
noTrailing: true })