gpt4 book ai didi

javascript - 防止为未打开的扩展面板呈现内部 html

转载 作者:行者123 更新时间:2023-11-30 20:47:27 26 4
gpt4 key购买 nike

我有以下 HTML:

  <mat-expansion-panel class="selected-history-panel" *ngFor="let e of elements;" [hideToggle]="hideToggle">

<mat-expansion-panel-header>{{e.uuid}}</mat-expansion-panel-header>

<div>
<app-history-item-tab-group></app-history-item-tab-group>
</div>

<mat-checkbox #showButtons>Reveal Buttons Below</mat-checkbox>

<mat-action-row *ngIf="true">
<button mat-button>DELETE ITEM 1</button>
</mat-action-row>

<mat-action-row *ngIf="showButtons.checked">
<button mat-button (click)="panel3.expanded = false">DELETE ITEM 2</button>
</mat-action-row>

</mat-expansion-panel>

数组中有大约 50 个元素。

此 View 需要一段时间才能加载 - 我假设是因为它正在呈现每个可扩展面板的内部内容。有没有办法使用 *ngIf 有条件地呈现内部内容?

最佳答案

所以我进行了这些更改,据我所知,渲染速度要快得多:

  <mat-accordion [displayMode]="displayMode" [multi]="multi" class="mat-expansion-demo-width">

<div style="overflow-y: scroll; max-height: 80vh;">

<mat-expansion-panel #daPanel class="selected-history-panel" *ngFor="let e of elements;" [hideToggle]="hideToggle">

<mat-expansion-panel-header>{{e.uuid}}</mat-expansion-panel-header>

<div *ngIf="daPanel.expanded === true">
<app-history-item-tab-group></app-history-item-tab-group>
</div>

<mat-checkbox #showButtons>Reveal Buttons Below</mat-checkbox>

<mat-action-row *ngIf="true">
<button mat-button>DELETE ITEM 1</button>
</mat-action-row>

<mat-action-row *ngIf="showButtons.checked">
<button mat-button (click)="panel3.expanded = false">DELETE ITEM 2</button>
</mat-action-row>

</mat-expansion-panel>

</div>


</mat-accordion>

更改是添加 #daPanel*ngIf

关于javascript - 防止为未打开的扩展面板呈现内部 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48554678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com