Arrays 关于包含colDefs和rowData的JSON数组的Angular构造函数中出现错误

Arrays 关于包含colDefs和rowData的JSON数组的Angular构造函数中出现错误,arrays,angular,Arrays,Angular,我有几个角度构造器正在使用Ag网格,但是得到了一个错误,我不知道为什么。该应用程序似乎可以工作,但这些错误发生在启动时,因此不允许我通过npm部署构建 在一个组件中,我得到了消息 ERROR in src/app/carsprods/carsprods.component.ts:24:4 - error TS2322: Type '[{ Name: string; Price: number; Category: string; }, { Name: string; Price: number

我有几个角度构造器正在使用Ag网格,但是得到了一个错误,我不知道为什么。该应用程序似乎可以工作,但这些错误发生在启动时,因此不允许我通过npm部署构建

在一个组件中,我得到了消息

ERROR in src/app/carsprods/carsprods.component.ts:24:4 
- error TS2322: Type '[{ Name: string; Price: number; Category: string; },
{ Name: string; Price: number; Category: string; }, 
{ Name: string; Price: number; Category: string; },
{ Name: string; Price: number; Category: string; }, 
{ ...; }, { ...; }, { ...; }]' is not assignable to type '[]'.
  **Source has 7 element(s) but target allows only 0.**
我的构造函数看起来像:

export class CarsprodsComponent {
private columnDefs;
private rowData: [];

  constructor() { 
                
 this.columnDefs = [
        { field: 'Name' },
        { field: 'Price' },
        { field: 'Category' }
    ];

  
   this.rowData = [
  { "Name": "Eaton BR120AF BR AFCI Circuit Breaker", "Price" : 2.50, "Category": "Power 
  Distribution / Arc Fault"},
  { .../
 "Category": "Battery / Batteries / AAA thru 9 Volt Batteries / Battery Type AAA"}
  ];
本例中的rowData数组有七个条目,然后我得到上面的粗体错误。 有人知道这个问题的解决方案吗?看起来解决起来不太难,但我不确定为什么会发生。也许我在构造函数中声明了错误的东西? 欢迎任何反馈!
谢谢

您应该像这样声明数组
私有行数据:any[]=[]

这是一个没有此类错误的示例