You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
338 B
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 防抖
* @param {Object} scope //引用的this发现不显式传this拿不到。
* @param {Object} fn
* @param {Object} delay
*/
let t = null
const debounce = function(scope, fn, delay) {
if (t !== null) {
clearTimeout(t)
}
t = setTimeout(() => {
scope[fn]()
}, delay)
}
export default debounce