element-plus reported an error ResizeObserver loop limit exceeded to solve

insert image description here
Not much to say, the error message looks like the above. Many solutions have been found on the Internet, such as ignoring this error in the onerror hook, so I uploaded my solution, the code is as follows:

const debounce = (fn, delay) => {
    
    
  let timer = null;
  return function () {
    
    
    let context = this;
    let args = arguments;
    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);
  }
}

This main.jscan be written in it, or it can be written in app.vueit, anyway, the page before this problem page appears.

Guess you like

Origin blog.csdn.net/qq_33733799/article/details/129873731