Uncaught runtime errors: ×
时间: 2023-11-05 11:21:28 浏览: 207
Uncaught runtime errors: × ERROR ResizeObserver loop limit exceeded 是一个运行时错误,它通常在使用Element-plus时在页面重置大小时出现。
这个错误是由webpack引起的,在webpack-dev-server的overlay.js文件中。它通常是由于观察元素的大小变化导致的循环问题引起的。
要解决这个问题,可以采取以下两种方法:
解决方案1:你可以在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);
}
}
```
解决方案2:如果你使用的是Vue Router 3.x版本,你可以在router/index.js文件中添加以下代码来禁用重复导航报错。
```javascript
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err);
}
```
通过采取以上两种方法中的一种,你应该能够解决Uncaught runtime errors: × ERROR ResizeObserver loop limit exceeded错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue项目报错:Uncaught SyntaxError: Unexpected token <](https://download.csdn.net/download/weixin_38593823/12949934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [element-plus 报错 ResizeObserver loop limit exceeded 解决](https://blog.csdn.net/qq_45112637/article/details/131740110)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Uncaught runtime errors: × ERROR Avoided redundant navigation to current location: “/xxx“.](https://blog.csdn.net/lplovewjm/article/details/130814946)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文