// ======================throttle.js
export default function () {
let delay = 300;
let fn;
if (arguments.length === 1) {
[fn] = arguments;
} else {
[delay, fn] = arguments;
}
let timer = null;
return function () {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, arguments), delay);
}
}
// vue页面 =======
import throttle from "@/utils/throttle";
throttle(function () {
this.xxFunc();
})