Throttle-debounce uses noTrailing to report an error callback.apply is not a function——solve

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:
insert image description hereBut using noTrailing to report an error in this way,callback.apply is not a function
insert image description here
so I checked the location of the error:
insert image description here
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 })

Guess you like

Origin blog.csdn.net/weixin_42566993/article/details/128092871