An explanation of throttling can be found in hereopen in new window.
Simply put, it is guaranteed to execute the function every N milliseconds. For example, for input events, the
throttle function will execute the function at a set time interval during the user input process. This is very different from the
debounce mentioned in the previous section.
The throttling of VueRequest is implemented using
throttleopen in new window provided by lodashopen in new window,
The leading and
trailing options default to true. Therefore, two requests may be triggered during the execution interval of the first throttle
throttleOptionsis provided after version 1.2.2 to customize the behavior of
As shown below, you only need to provide a
throttleInterval to tell us the execution interval of throttling. So when the user enters information, we will initiate a request every 1000 milliseconds.
You can open the console to view the interval of the console printing information