我正在尝试通过 2 个嵌套的 ngFor 显示 2d 数组
<div class="row" *ngIf="!calculating" style="margin: auto;">
<div class="col-xs-12 col-sm-12 col-md-12 col-sm-offset-1 col-md-offset-2">
<div class="row" *ngFor="let pixelRow of pixels" style="width: max-content;">
<div class="col pixel"
*ngFor="let pixel of pixelRow"
[ngStyle]="{'background-color': pixel.Color }"
(click)="changePixelState(pixel.xIndex, pixel.yIndex)"></div>
</div>
</div>
</div>
基本上它在正常的数据规模上工作正常,但是当它被定义为 1000X1000 时 - 显示需要大量时间,同时页面没有响应。我曾尝试使用 cdk-virtual-scroll-viewport 但我找不到任何关于如何在二维数组上使用它的文档,只能在一个数据列表中找到。
我能做些什么?有任何想法吗?