gpt4 book ai didi

angular - 错误类型错误 : Class constructor EventEmitter_ cannot be invoked without 'new'

转载 作者:行者123 更新时间:2023-12-04 12:58:31 28 4
gpt4 key购买 nike

升级到 Angular 10 后,某些组件出现以下错误 -

ERROR TypeError: Class constructor EventEmitter_ cannot be invoked without 'new'
at new ZoneAwareEventEmitter (index.js:34)
at new GridComponent (index.js:6167)
at createClass (core.js:21921)
at createDirectiveInstance (core.js:21790)
at createViewNodes (core.js:30281)
at callViewAction (core.js:30597)
at execComponentViewsAction (core.js:30516)
at createViewNodes (core.js:30309)
at callViewAction (core.js:30597)
at execComponentViewsAction (core.js:30516)
导致此问题的代码 -
import { EventEmitter } from "@angular/core";

export class ZoneAwareEventEmitter extends EventEmitter {
constructor(ngZone, isAsync = false) {
super(isAsync);
this.ngZone = ngZone;
}
}
我错过了什么吗?
在此先感谢您的帮助!

最佳答案

将此添加到 Webpack 配置:

resolve: {
mainFields: ['es2015', 'browser', 'module', 'main']
},

该问题发生在使用 Kendo Angular Grid 的项目中的 Webpack 构建中.默认的 Webpack 配置解决了 fesm5模块来自 node_modules/@progress/kendo-angular-grid ,它尝试使用 es5 扩展 EventEmitter 类并导致错误。更改 mainFields resolve 的属性(property)在 Webpack 配置中设置优先级 es2015模块为我解决了这个问题。

关于angular - 错误类型错误 : Class constructor EventEmitter_ cannot be invoked without 'new' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62692676/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com