我正在使用 Angular Material Virtual 滚动,项目被正确加载到 DOM 中,但是在滚动时它会跳来跳去并自动跳到最后。
<cdk-virtual-scroll-viewport #scrollViewport (scrolledIndexChange)="scrolled($event)" [itemSize]="ITEM_SIZE" class="my-virtual" >
<div *cdkVirtualFor="let elem of elemtArray;" class="input-field-container ">
<div class="my-style" >{{elem}} </div>
</div>
</cdk-virtual-scroll-viewport>
如果发生故障,则滚动方法的输出如下:
Scrolled: 105
Scrolled: 115
Scrolled: 106
Scrolled: 117
Scrolled: 109
Scrolled: 119
Scrolled: 110
Scrolled: 121
如果发生这种情况,它会自动滚动到虚拟滚动的末尾。