我有这个代码:
@Input() data: Array<Users>;
@ViewChild(MatSort, { static: false }) sort: MatSort;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator;
dataSource: MatTableDataSource<Users> = new MatTableDataSource();
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.dataSource.data = this.data;
}
分页器和排序不起作用,我有全部 7000 行,而且速度非常慢。接下来我可以尝试什么?
您必须覆盖数据源并保持正确的步骤顺序。
ngAfterViewInit() {
this.dataSource = new MatTableDataSource<Users>(this.data);
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
}