Skip to content

Instantly share code, notes, and snippets.

@evolify
Last active July 26, 2022 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evolify/e06ceec7ffef33fdcb3e656dfa1cbedb to your computer and use it in GitHub Desktop.
Save evolify/e06ceec7ffef33fdcb3e656dfa1cbedb to your computer and use it in GitHub Desktop.
节流、防抖
export function debounce(callback, wait) {
let timeoutId = null;
return (...args) => {
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
callback.apply(null, args);
}, wait);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment