vue3打开弹框显示错误 ResizeObserver loop completed with undelivered notifications. 怎么解决啊
时间: 2023-11-07 18:05:51 浏览: 183
vue-resize-observer:Vue调整大小观察器
5星 · 资源好评率100%
解决办法是在app.vue和main.js中添加以下代码:
```javascript
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);
}
};
```
这段代码会解决报错"ResizeObserver loop completed with undelivered notifications."的问题。具体原因是因为在vue3中使用element-plus时,el-table的尺寸发生变化时,window.ResizeObserver计算尺寸时出了问题。而以上代码会通过添加debounce函数和重写ResizeObserver来解决这个问题。
阅读全文