js throttle 节流

// ======================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();
 })
原文地址:https://www.cnblogs.com/luoxuemei/p/13679760.html