什么是[ngSwitch]
和一堆*ngIf
之间的区别?我们应该关注哪些性能因素?
*ngIf
:最初的回答 <div *ngIf="day === 'MONDAY'">
Keep calm and pretend it's not Monday.
</div>
...
<div *ngIf="day === 'FRIDAY'">
Happy Friday!
</div>
[ngSwitch]
<ng-container [ngSwitch]="day">
<div *ngSwitchCase="'MONDAY'">
Keep calm and pretend it's not Monday.
</div>
...
<div *ngSwitchCase="'FRIDAY'">
Happy Friday!
</div>
</ng-container>