throttle-debounce.js:一个小型的防抖节流函数库

Throttle and debounce functions.

文档:

Node.js

安装

npm install throttle-debounce --save

示例

import {
    
     throttle, debounce } from 'throttle-debounce';

// delay 100 or 250 
throttle(delay, callback, {
    
     noLeading=false, noTrailing=false, debounceMode })

debounce(delay, callback, {
    
     atBegin=false })

CDN

<!-- 引入throttle-debounce -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/umd/index.min.js"></script>

<script>
const throttleFunc = throttleDebounce.throttle(1000, ()=>{
      
      });

const debounceFunc = throttleDebounce.debounce(1000, ()=>{
      
      });
</script> 

猜你喜欢

转载自blog.csdn.net/mouday/article/details/125444857