首页 文章

Angular Material v6 Mat-Footer - “无法读取属性'template' of undefined”

提问于
浏览
2

为了这个目的,我最近在升级到角度6之后尝试在mat-table组件中实现一个页脚行,但是在表格中添加mat-footer-cell和mat-footer-row元素后,我得到以下内容错误:

错误TypeError:无法在MatFooterRowDef.push中读取未定义的属性'template'./ node_modules/@angular/cdk/esm5/table.es5.js.CdkFooterRowDef.extractCellTemplate(vendor.js:17400)

该表仍显示在页面上,但没有数据,没有页脚行,并且每个列 Headers 右侧的T符号 .

HTML:

<ng-container matColumnDef="total">

    <mat-header-cell *matHeaderCellDef mat-sort-header style="width: 15%; flex: none">Total</mat-header-cell>

    <mat-cell *matCellDef="let item" style="width: 15%; flex: none">{{item.total | currency: 'GBP'}}</mat-cell>

    <td mat-footer-cell *matFooterCellDef>100</td>

  </ng-container>

  <mat-header-row *matHeaderRowDef="tableColumns"></mat-header-row>

  <mat-row *matRowDef="let row; columns: tableColumns" (click)="editItem(row)"></mat-row>

  <tr mat-footer-row *matFooterRowDef="tableColumns"></tr>

</mat-table>

1 回答

  • 20

    修复:在材料文档中没有明确说明,但 all 列必须包含 <mat-footer-cell/> 元素,即使只有一列包含内容 .

相关问题