在服务Angular应用程序时,出现Angular v10中的控制台错误以下情况
core.js:4197 ERROR TypeError: Cannot call a class as a function at _classCallCheck (classCallCheck.js:3) at new Button (button.js:36) at ButtonComponent.<anonymous> (createSuper.js:12) at new ButtonComponent (button.component.ts:30) at NodeInjectorFactory.ButtonComponent_Factory [as factory] (button.component.ts:57) at getNodeInjectable (core.js:4029) at instantiateAllDirectives (core.js:8092) at createDirectivesInstances (core.js:7474) at ɵɵelementStart (core.js:14001) at SBController_Template (template.html:114)
演示:https://github.com/kumaresan-subramani/AngularSampleIssue
复制步骤:
有角团队的答案-https://github.com/angular/angular-cli/issues/18125#issuecomment-672069800
答案 0 :(得分:1)
我确实看过你的回购。看来您的target
文件中的ES es5
已设置为tsconfig.base.json
,但不支持类。我认为您必须至少从es6
(es2015
)进行设置,然后才能正常工作:
{
"compilerOptions": {
"target": "es2015",
}
}