ResizeObserver loop limit exceeded 报错解决

复制如下代码到main.js即可,  放在Vue.use 之前。

TS

const debounce = (fn: any, delay: any, ...value: any) => {
  let timer: any = null;
  return () => {
    let context = this;
    let args = value;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback: any) {
    callback = debounce(callback, 16);
    super(callback);
  }
};

JS

const debounce = (fn, delay, ...value) => {
  let timer = null;
  return () => {
    let context = this;
    let args = value;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
};

你可能感兴趣的:(java,前端,javascript,vue,elementui)