C'est La Vie

    人生无彩排,每一天都是现场直播!

    JavaScript简单的防抖函数

    直接上代码:

    直接上代码:

    function debounce(fn, time) {
        return function(args) {
            let that = this
            clearTimeout(fn.tid)
            fn.tid = setTimeout(() => {
                fn.call(that, args)
            }, time);
        }
    }
    

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用*标注