gpt4 book ai didi

javascript - 最小 Material 表演示 ID 列未呈现?

转载 作者:行者123 更新时间:2023-11-30 13:54:21 24 4
gpt4 key购买 nike

<分区>

我正在尝试创建 a minimal material table demo - Note this is a stackblitz link并且 id 列未呈现。这是 app.component.ts:

    import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from "@angular/material";
class Todo {
id: string;
description: string;
complete: boolean;
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
displayedColumns: ['id', 'description', 'complete'];
dataSource: MatTableDataSource<Todo>;

ngOnInit() {
const todos: Todo[] = [{ id: '123', description: 'Complete me!', complete: false }];
this.dataSource = new MatTableDataSource(todos);
}
}

这是模板:

    <mat-table class="mat-elevation-z8" [dataSource]="dataSource">
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef>ID</mat-header-cell>
<mat-cell *matCellDef="let row;">{{row.id}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns">
</mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
</mat-table>

想法?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com