防抖

2021-09-07  本文已影响0人  帆_44fc
 timeout: null,
 count: 0
fn(name) {
            if (this.count == 0) {
                this.count++;// 第一次点执行
                // console.log(this.count,'count')
                this.handleSubmit1(name);
            } else {
                if (this.timeout) {
                    clearTimeout(this.timeout);
                }
                this.timeout = setTimeout(() => {
                this.handleSubmit1(name);
                    // console.log('222');
                }, 500);
            }
        },

参考:https://www.jianshu.com/p/36cedce3d1d9

上一篇 下一篇

猜你喜欢

热点阅读