1

我想做这样的事情:

<cdk-virtual-scroll-viewport [itemSize]="25">
  <svg>
    <g *cdkVirtualFor="let item of items">...</g>
  </svg>
  <div *cdkVirtualFor="let item of items">...</div>
</cdk-virtual-scroll-viewport>

并让gdiv元素同时滚动(它们都具有相同的高度)。这可能吗?完全按照我在此处概述的操作会导致错误:Error: CdkVirtualScrollViewport is already attached.

4

1 回答 1

1

以下是我如何使用虚拟滚动实现 2 个列表:我合并列表、添加类型、按类型对列表进行排序,并在类型更改时中断:

ts file:
    didGroupChange(jobNow:JobsResponse, jobPrev:JobsResponse){
            return jobNow.type!==jobPrev?.type;
        }
HTML:
    <cdk-virtual-scroll-viewport [itemSize]="20" class="scroll-panel-jobs">                         
    <dl>
        <ng-container *cdkVirtualFor="let job of  country?.jobsList;  let index = index;">
             <dt *ngIf="didGroupChange(job,country?.jobsList[index-1])" class="line row h15 title-job">{{job.type}}</dt>    
             <dd class="line row h16">{{job.title}} </dd>                     
        </ng-container>
      </dl>                 
</cdk-virtual-scroll-viewport>
于 2020-10-27T19:50:22.657 回答