Javascript p在jquery.dataTables.min.js中是什么意思?

Javascript p在jquery.dataTables.min.js中是什么意思?,javascript,jquery,angular,datatable,angular-datatables,Javascript,Jquery,Angular,Datatable,Angular Datatables,当我尝试使用angular with ECMAScript 5为项目环境呈现数据表时,我在控制台中遇到了这个错误(对此我无能为力) 错误类型错误:p未定义 我读了1000个类似的问题,表中tr的数量等于th的数量,表中没有colspan标记或任何其他不受支持的功能,事实上,这再简单不过了。。。在这个项目中,还有其他的数据表,它们在相同的结构下工作得很好。我已经花了三天的时间试图弄明白这一点,但没有运气。拜托,拜托,拜托,我需要社区的帮助 getCurationsList(){ this.

当我尝试使用angular with ECMAScript 5为项目环境呈现数据表时,我在控制台中遇到了这个错误(对此我无能为力)


错误类型错误:p未定义

我读了1000个类似的问题,表中tr的数量等于th的数量,表中没有colspan标记或任何其他不受支持的功能,事实上,这再简单不过了。。。在这个项目中,还有其他的数据表,它们在相同的结构下工作得很好。我已经花了三天的时间试图弄明白这一点,但没有运气。拜托,拜托,拜托,我需要社区的帮助

getCurationsList(){
    this.commonService.getCurations().subscribe(
      result => {
        if (result[0]) {
          this.curation.curations = result[1];
          this.globals.tableCurationVisible = false;
          
            setTimeout(() => {
              const table = $('#dataTableCurations').DataTable({
                /*Ordering by date */
                // autoWidth: false,
                deferRender: true,
                ordering: true,
                pageLength: 10,
                columnDefs: [{ 'type': 'date-euro', 'targets': 2 }],
                order: [[1, 'desc']],
                destroy: true
              });

              if (this.curation.curations.length > 0) {
                this.curation.name = $('#dataTableCurations tbody tr:first td:first').text();
              for(let i=0; i<this.curation.curations.length;i++){
                  console.log(this.curation.curations[i]);
                  let icur = this.curation.curations[i];
                  this.curation.name = icur['curation_endpoint'];
                  this.curation.date = icur['creation_date'];
              }
                    }
              this.globals.tableCurationVisible = true;
            }, 10);
          } 
          else {
            alert(result[1]);
          }
        },
        error => {
          alert(error.message);
        }
    )
  }

}
getCurationsList(){
此.commonService.getCurations()订阅(
结果=>{
如果(结果[0]){
this.curation.curations=结果[1];
this.globals.tableCurationVisible=false;
设置超时(()=>{
常数表=$(“#dataTableCurations”).DataTable({
/*按日期订购*/
//自动宽度:false,
是的,
顺序:对,
页长:10,
columnDefs:[{'type':'date euro','targets':2}],
订单:[[1,'说明']],
毁灭:真的
});
如果(this.curation.curations.length>0){
this.curation.name=$('#dataTableCurations tbody tr:first td:first').text();
for(设i=0;i{
警报(错误消息);
}
)
}
}
这些值在this.curation.curations中正确存储/从响应中解救,我可以从component.ts访问它们,事实上,如果我为表(不是dataTable)放置任何其他id值,我就有一个完美的表,其中所有内容的顺序和位置都正确,但项目要求我使用dataTables

以下是html:

 <table id="dataTableCurations" class="table" style="width:100%">
        <thead>
          <tr>
            <th style="width: 12%">Name</th>
            <th style="width: 12%">Date</th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let item of this.curation.curations" (click)= "selectCuration(item['curation_endpoint'], item['creation_date'])" [ngClass]="{'selected': this.curation.name===item['curation_endpoint']}">
              <td>{{item['curation_endpoint']}}</td>
              <td>{{item['creation_date']}}</td>
          </tr>
        </tbody>
      </table>

名称
日期
{{item['curation_endpoint']}
{{item['creation_date']}

非常感谢您的帮助。

谢谢andrewjames。问题出在ColumnDefs中,它是以零为基础的,因此列数也必须从0开始。更改此选项有效:

columnDefs: [{ 'type': 'date-euro', 'targets': 1 }],//because there are two columns

p是未定义的听起来像是一个被调用但未定义的变量-但是在你发布的代码中没有-你能用行号等来发布整个错误消息吗?错误类型错误:p是未定义的jQuery 13 getCurationsList common.functions.ts:345//这行=const table…在上面的代码中是16 GetCurationsLSt common.functions.ts:344 RxJS 14 Angular 16 RxJS 8 Angular 10并且我这边没有调用p,也许jQuery datatables需要这个,但我找不到任何引用。无论如何,感谢您的审阅。要获得更详细的消息,请将最小化的JS资源更改为未最小化的资源。这样,变量名u see可能更有意义(或者,至少,它们将更少…最小化)。尽管如此,如果HTML中定义的列数与DataTables预期的列数不匹配,则可能会发生此错误。在您的情况下,HTML有2列(名称和日期),但是
columnDefs
只引用了1列,更糟糕的是,它的索引是
2
,这意味着“第三列”,因为列索引是以零为基础的。我从这里开始。