The problem of Anonymous function in the throttling of vue function

question
this is the original function throttling method: anonymous function

(Note: return function () {} cannot be executed in methods )

excuse me, how can I change it to vue version?

as it is very commonly used in scrolling and Chinese search boxes, please consult

paste code:

created(){
    window.addEventListener("scroll", () => {
        this.debounce()(this._log, 1000);
    }
},
methods: {
    debounce (fn, idle) {
      let setTm;
      console.log("debounce")
      if (!idle || idle <= 0) return fn;
      return function () {
        clearTimeout(setTm);
        setTm = setTimeout(fn.bind(this, ...arguments), idle);
      }
    },
    _log(){
        console.log("_log")
    },
    
}

the way to bind should be:

var throttle = (fun, wait = 5000) => {
    var last = 0;
    return function () {
        var args = arguments;
        var ctx = this;
        var now = Date.now();
        if (now - last >= wait) {
            last = now;
            return fun.apply(ctx, args);
        }
        console.log(``)
    }
}

export default {
    name: 'VueComponent',
    methods: {
        scroll: throttle(function () {
            //...
        })
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3e13b-43adf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3e13b-43adf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?