virtual scroll on Angular 7 is not visible - the height is zero by default

后端 未结 3 919
一向
一向 2021-01-05 10:58

Scenario:

  • Tried a basic virtual scroll test reading this blog post
  • the array had lots of items
  • there was no error
  • t
3条回答
  •  鱼传尺愫
    2021-01-05 11:21

    • use min-height of 100% for the viewport and verify
    • make sure, the height set on the viewport with 'itemSize' matches the height of the item in css
    • if you are using an Observable, make sure to resolve it with *ngIf and the async pipe. Important: the html element is an ng-container, because it may not be rendered for the min-width to work!

        .list {
           min-height: 100%;
        }
      
        .item {
           height: 100px;
        }
      

    When using an Observable as a source

    
      
    

提交回复
热议问题