ng-docs.github.io icon indicating copy to clipboard operation
ng-docs.github.io copied to clipboard

*ngFor 循环内容中包含组件,导致页面渲染变慢

Open qwz873112851 opened this issue 5 years ago • 2 comments

使用*ngFor循环生成表格元素,内部有八九个操作按钮,大部分是下拉菜单,我把所有按钮封装再一个组件内,页面在渲染的时间在两到三秒左右 浏览器警告 [Violation] 'load' handler took 2054ms;onPush使用过,并没有什么提升,请问还有什么优化方法? <ng-container *ngFor="let item of Arr"> <a nz-dropdown [nzDropdownMenu]="dropdown"> 下拉菜单 <nz-dropdown-menu #collectFolder="dropdown"> <ul nz-menu nzSelectable style="overflow-y: auto;max-height: 150px;"> <li nz-menu-item *ngFor="let item of collectFoldersList"> <a href="javascript:void(0)" (click)="saveInfo()">{{ item.name }}

qwz873112851 avatar Sep 29 '20 09:09 qwz873112851

可以用ngzone把相关操作移出到ng环境外执行,等执行完后再触发变更 如果还慢,只能加worker解决了

wszgrcy avatar Sep 29 '20 11:09 wszgrcy

感觉是你场景设计太复杂了,使用nz-table会不会好一点

magyy521 avatar Oct 28 '20 07:10 magyy521