当前位置:网站首页>JS tool function, self encapsulating a throttling function

JS tool function, self encapsulating a throttling function

2022-06-25 03:52:00 51CTO

```js /** * * @param fn Function of throttling * @param delay Delay time * @returns Throttled function */ let debounceTimer = '' export function debounce(fn, delay = 700) { clearTimeout(debounceTimer) debounceTimer = setTimeout(() => { fn() }, delay) } ``` # Very simple to use ```js debounce(this.getQuery, 600) ``` ### There are many ways , Please leave a message in the comment area , Write your method . > This paper is written by snailPush One click publishing platform [snailPush](http://localhost:8080/publish/article) Release !
原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250332315827.html

随机推荐