W
e
l
c
o
m
e
: )

解决ERROR ResizeObserver loop completed with undelivered notifications.

https://www.cnblogs.com/luo9tian/p/18116299

该报错虽然不影响项目运行,但是影响开发效率,总是弹出报错的黑框很烦人

该报错原因:new ResizeObserver包裹的方法,在布局发生变化时,不支持每帧都调用

解决方法:用 window.requestAnimationFrame包裹回调函数

App.vue/main.js中加入以下这段代码即可解决:

// app.vue写在script里面  main.js写在app挂载完之后
const debounce = (fn, delay) => {
  let timer
   return (...args) => {
     if (timer) {
       clearTimeout(timer)
     }
     timer = setTimeout(() => {
       fn(...args)
     }, delay)
   }
}
const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver{
   constructor(callback) {
     callback = debounce(callback, 200);
     super(callback);
   }
}
posted @ 2024-10-09 11:02  眈眈逐逐  阅读(226)  评论(0编辑  收藏  举报