处理报错 ResizeObserver loop completed with undelivered notifications.

// 处理报错 ResizeObserver loop completed with undelivered notifications.
export const handlerResizeObserverError = () => {
  const debounce = (callback: (...args: any[]) => void, delay: number) => {
    let tid: any;
    return function (...args: any[]) {
      const ctx = self;
      tid && clearTimeout(tid);
      tid = setTimeout(() => {
        callback.apply(ctx, args)
      }, delay)
    }
  }

  const _ = (window as any).ResizeObserver;
  (window as any).ResizeObserver = class ResizeObserver extends _ {
    constructor(callback: (...args: any[]) => void) {
      callback = debounce(callback, 20)
      super(callback)
    }
  }
}

 

posted @ 2024-04-26 09:35  SKILL·NULL  阅读(10)  评论(0编辑  收藏  举报