【发布时间】:2021-01-04 22:39:31
【问题描述】:
如果我添加此行<ng-container *ngIf="productColor.images">,Swiper 将根本无法工作,并且在控制台中不会显示任何错误。知道如何解决这个问题吗?
<swiper *ngIf="productColors" [slidesPerView]="1" [spaceBetween]="50" (swiper)="onSwiper($event)" (slideChange)="onSlideChange()">
<ng-container *ngFor="let productColor of productColors._embedded.productColors">
<ng-container *ngIf="productColor.images">
<ng-container *ngFor="let image of productColor.images._embedded.images">
<ng-template swiperSlide>
<img [src]="server.cloudFront + image.url" alt="Oops!" style="max-width: 100%">
</ng-template>
</ng-container>
</ng-container>
</ng-container>
</swiper>
这是一个例子:https://stackblitz.com/edit/swiper-angular-example-j8jxpp?file=src/app/app.component.ts
【问题讨论】:
-
请在您的代码中添加一个最小复制示例(例如通过 StackBlitz)。那么帮助你就容易多了。阅读有关它的更多信息 stackoverflow.com/help/minimal-reproducible-example
-
@Roy 我刚刚添加了一个简单的示例,请看一下。谢谢。