Angular 10集成Kendo Grid报‘Class constructor vA无法无new调用’错误求助
Angular 10 集成 Kendo Grid 出现
Class constructor vA cannot be invoked without 'new' 错误排查方案 以下是针对该错误的具体排查和解决步骤:
1. 严格匹配 Kendo UI 与 Angular 10 的版本兼容性
Angular 10 仅兼容 @progress/kendo-angular-grid@5.x 系列版本,高版本(6.x+)会因使用 ES6+ 类特性导致与 Angular 10 编译环境冲突:
- 执行命令查看当前版本:
npm list @progress/kendo-angular-grid - 若版本过高,降级到兼容稳定版:
npm install @progress/kendo-angular-grid@5.12.0 --save
2. 完善 tsconfig.json 编译配置
除了将 target 设为 es6,需补充关键配置确保 ES6+ 特性支持:
{ "compilerOptions": { "target": "es6", "module": "es2020", "lib": ["es2018", "dom"], "downlevelIteration": true, "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true } }
downlevelIteration必须设为true,解决 Kendo Grid 内部迭代器特性的编译问题
3. 补充必要的 Polyfill
确保 polyfill.ts 中包含 ES6+ 类相关的 polyfill,避免运行时缺失特性支持:
import 'core-js/es/reflect'; import 'core-js/es/object'; import 'core-js/es/class';
若之前注释了这些导入,取消注释后重新编译。
4. 验证模块导入正确性
检查组件所在模块的导入逻辑,避免重复或错误导入:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { GridModule } from '@progress/kendo-angular-grid'; import { QueueGridComponent } from './queue-grid.component'; @NgModule({ declarations: [QueueGridComponent], imports: [BrowserModule, GridModule], exports: [QueueGridComponent] }) export class QueueGridModule { }
5. 彻底清理缓存并重建项目
执行以下命令清除所有缓存和旧构建文件,避免缓存导致的版本冲突:
rm -rf node_modules package-lock.json npm cache clean --force npm install ng build --delete-output-path
6. 简化 Grid 配置定位问题
将组件模板和数据简化到最基础形态,排除自定义模板/指令的干扰:
- 模板代码:
<kendo-grid [data]="gridData"> <kendo-grid-column field="id" title="ID"></kendo-grid-column> <kendo-grid-column field="name" title="Name"></kendo-grid-column> </kendo-grid>
- 组件数据:
gridData = [{ id: 1, name: 'Test Item 1' }, { id: 2, name: 'Test Item 2' }];
若基础版本可正常运行,再逐步添加自定义配置,定位问题节点。
内容的提问来源于stack exchange,提问作者Its_me_Jithu
相关产品推荐
相关产品推荐

