ng-docs.github.io
ng-docs.github.io copied to clipboard
*ngFor 循环内容中包含组件,导致页面渲染变慢
使用*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 }}
可以用ngzone把相关操作移出到ng环境外执行,等执行完后再触发变更 如果还慢,只能加worker解决了
感觉是你场景设计太复杂了,使用nz-table会不会好一点