我在 Angular 11 中使用 cdk-virtual-scroll-viewport 进行虚拟滚动
我想在子表行上显示虚拟滚动,所以我怎样才能只为表行实现,这是我的表和代码的屏幕截图。
<cdk-virtual-scroll-viewport [itemSize]="100" style="height: 450px;"> <table class="table table-bordered tabledesign"> <thead> <tr> <th [style.top]="inverseOfTranslation" style="position: sticky !important;" *ngFor="let col of columns"> {{ col.title }} </th> </tr> </thead> <tbody> <ng-container *ngFor="let row of rows; let i = index"> <tr> <ng-container *ngFor="let col of columns"> <ng-container [ngSwitch]="col.type"> <td *ngSwitchCase="'expandIcon'"> <span *ngIf="row.child && row.child.length"> <a *ngIf="!row.showChild" (click)="row.showChild = true"> <i class="fa fa-plus-square-o plus-icon"></i> </a> <a *ngIf="row.showChild" (click)="row.showChild = false"> <i class="fa fa-minus-square-o plus-icon"></i> </a> </span> </td> </ng-container> </ng-container> </tr> <ng-container *ngIf="row.child && row.showChild"> <tr *cdkVirtualFor="let childParameter of row.child; let cInd=index;"> <ng-container *ngFor="let col of childColumns"> <ng-container [ngSwitch]="col.type"> <td *ngSwitchCase="'custom_sr'"> 1.1 </td> </ng-container> </ng-container> </tr> </ng-container> </ng-container> </tbody> </table> </cdk-virtual-scroll-viewport>
我只想为子表行添加虚拟滚动