11-函数防抖

2019-05-15  本文已影响0人  仰望_IT
    let oInput = document.querySelector("input");
    let timerId = null;

    oInput.oninput = function () {
        timerId && clearInterval(timerId);
        timerId = setTimeout(function () {
            console.log("发生网络请求");
        }, 1000);
    }
上一篇 下一篇

猜你喜欢

热点阅读