我正在使用 p表 virtualScroll和Primeng Angular 9中的预加载数据。 当我向下滚动时,滚动会非常平滑,但是当我向上滚动时,会有1到2秒钟的延迟和白色背景,然后数据才会显示在屏幕上。
这是我的代码:
<p-table class="book-table" #bookTable [columns]="columns" [value]="books" [scrollable]="true" [rows]="50"
[scrollHeight]="scrollHeight" // dynamic height [virtualScroll]="true" [virtualRowHeight]="30" [rowTrackBy]="trackByBookId">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
{{col.header}}
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-book let-i="rowIndex">
<tr style="height:30px" #rows id="{{book.id}}">
<td>{{book.name}}</td>
<td>
<div *ngIf="bookVersions(book.id).length >= 1" style="display:inline">
<span #versions *ngFor="let version of versions;">
<span *ngIf="version.bookId === book.id" class="version-label">
<a (click)="editVersion(book.id); style="cursor:pointer">{{version.number}}</a>
</span>
</span>
</div>
</td>
<td>{{book.releasedDate}}</td>
<td>
<div *ngIf="bookReaders(book.id).length >= 1" style="display:inline">
<span #readers *ngFor="let reader of readers;">
<span *ngIf="reader.bookId === book.id" class="reader-label">
<span>{{reader.name}}</a>
</span>
</span>
</div>
</td>
</tr>
</ng-template>
</p-table>
为什么向上滚动时我有1到2秒的延迟,而向下滚动时却没有?