function debounce(func, delay) {
let timerId;
return (...args) => {
clearTimeout(timerId);
timerId = setTimeout(() => {
func(...args);
}, delay);
};
}
function myFunction() {
console.log('Debounced function called');
}
const debouncedClick = debounce(myFunction, 1000);
<button @click="debouncedClick">点击按钮</button>