我用了bootstrap 5 carousel,它在我的本地運行良好。但是它在構建和發布到產品之后就崩潰了。我不知道為什么。
我在這里附上我的代碼供您參考。提前感謝。
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" *ngIf="banners.length">
<div class="carousel-indicators">
<button *ngFor="let item of banners; let i = index"
type="button"
[attr.data-bs-target]="'#carouselExampleIndicators'"
[attr.data-bs-slide-to]="i"
[class.active]="i === 0"
[attr.aria-current]="i === 0 ? 'false' : null">
</button>
</div>
<div class="carousel-inner">
<div class="carousel-item active " *ngFor="let item of banners">
<img loading="eager" [ngSrc]="item?.image" class="d-block" width="1480" height="405" style="height: fit-content; width: 100%">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>