@iap Packages
    Preparing search index...

    Function throttle

    • 节流函数——在 limit 毫秒内最多执行一次

      Type Parameters

      • T extends (...args: unknown[]) => unknown

      Parameters

      • fn: T

        待节流的原始函数

      • limit: number

        节流间隔毫秒数

      Returns (...args: Parameters<T>) => void

      经过节流封装的函数,与 fn 具有相同入参

      const handleScroll = throttle(() => updateHeader(), 100)