Lodash 是一个一致性、模块化、高性能的 JavaScript 实用工具库。
Lodash 简介 | Lodash中文文档 | Lodash中文网 (lodashjs.com)
第一步:下载 npm install --save lodash
第二步:引入lodash import * as _ from 'lodash'
什么是防抖和节流?如何实现防抖和节流?_王者荣耀 防抖节流-CSDN博客
_.
debounce (func, [wait=0], [options=])
参数:
- func (Function): 要防抖的函数。
-
wait=0\] (number): 需要延迟的毫秒数。
-
options.leading=false\] (boolean): 指定在延迟开始前调用,默认false
-
options.trailing=true\] (boolean): 指定在延迟结束后调用
参数:
- func (Function): 要节流的函数。
-
wait=0\] (number): 需要节流的毫秒。
-
options.leading=true\] (boolean): 指定调用在节流开始前,默认true