某事件在规定时间后才能进行,如果在这段时间内再次触发,则重新开始计时。
简易版:
/**
* 输入框防抖
* @param {Object} fn 运行的函数
* @param {Object} wait 等待时间
*/
debounce(fn, wait) {
if (this.setTimeoutItem !== null) {
clearTimeout(this.setTimeoutItem);
}
this.setTimeoutItem = setTimeout(fn, wait);
},