Vue 学习笔记 错误ResizeObserver loop completed with undelivered notifications

环境Vue3 Ts

使用了el-table 后,容易出现如下错误

ERROR

ResizeObserver loop completed with undelivered notifications.

at handleError (webpack-internal:///./node_modules/webpack-dev-server/client/overlay.js:299:58)

at eval (webpack-internal:///./node_modules/webpack-dev-server/client/overlay.js:318:7)

解决办法

在App.vue 下面加代码

javascript 复制代码
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);
      }
    };
  },

App.vue 完整代码如下:

javascript 复制代码
<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  setup() {
    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);
      }
    };
  },
});
</script>
<style lang="scss"></style>

为什么??? 我也不清楚原理

ChatGPT 解释如下:

相关推荐
alibaba_张无忌38 分钟前
金融学期末速成笔记
笔记·金融
Back~~41 分钟前
MFC1(note)
学习
神夜大侠1 小时前
VUE 实现公告无缝循环滚动
前端·javascript·vue.js
明辉光焱1 小时前
【Electron】Electron Forge如何支持Element plus?
前端·javascript·vue.js·electron·node.js
engchina1 小时前
Oracle ADB 导入 BANK_GRAPH 的学习数据
数据库·学习·oracle·graph
Komorebi.py2 小时前
【Linux】-学习笔记03
linux·笔记·学习
程序员劝退师_3 小时前
Kafka学习笔记
笔记·学习·kafka
帅比九日3 小时前
【HarmonyOS NEXT】实战——登录页面
前端·学习·华为·harmonyos
李笠^_^3 小时前
Python学习------第八天
学习
Lotay_天天3 小时前
删库跑路,启动!
学习