<ul class="row collapse no-bullet" *ngIf="items">
<li class="columns" [ngClass]="columnSize" *ngFor="#item of items">
<a href="...">
<img class="orbit-image" [src]="getImageSrc(item.image.thumb250)">
<figcaption class="orbit-caption">{{item.location.city}}{{item.handle}}</figcaption>
</a>
</li>
</ul>
VS
<ul class="row collapse no-bullet">
<li class="columns" [ngClass]="columnSize" *ngFor="#item of items">
<a href="...">
<img class="orbit-image" [src]="getImageSrc(item?.image?.thumb250)" [alt]="item?.caption">
<figcaption class="orbit-caption">{{item?.location?.city}} {{item?.handle}}</figcaption>
</a>
</li>
</ul>
用什么比较好?ngIf在数据准备好后不渲染项目或使用Elvis运算符来避免未定义的值。