有一个材料表组件,其中包括虚拟滚动。几秒钟的中断后,我正在尝试进行一些更改和虚拟滚动。
ngOnChanges
表组件的钩子:
ngOnChanges(changes: SimpleChanges) {
this.init();
this.headers = ["DATE","AMERICA","EUROPE","AUSTRALIA","ASIA"];
this.displayedColumns = this.headers;
this.tableDataService.getData()
.map(data => {
this.tableData.push(data);
this._alldata = this.tableData.map((val =>
val.reduce((headerVal, data, index) =>
({ ...headerVal, [this.headers[index]]: data }), {})
));
this.dataSource.allData = this._alldata.slice(0, this.pageSize);
},
(err: any) => console.log(err))
}
stackblitz上再现了这种情况,单击表格上方的按钮,出现了问题。