1. export function throttle(callback, timeout) {
    2. let startTime = 0;
    3. return (...args) => {
    4. let nowTime = Date.now();
    5. // 第一次会执行,后面 startTime = nowTime
    6. if(nowTime - startTime >= timeout) {
    7. callback.call(this, ...args);
    8. startTime = nowTime;
    9. }
    10. }
    11. }