javascript - 猫头鹰轮播不会加载图像和按钮
问题描述
我在我的 Angular 应用程序中使用 owl carousel,我正在发送 API 请求以获取项目并使用 owl carousel 在页面中显示它们。
我正在显示引导卡中的项目并且它工作正常但是一旦我将循环设置为 true 卡中的图像就没有被加载,即使我已经得到了响应并且我可以在控制台中看到我的所有项目但是当我在轮播中的项目之间滚动,就像延迟加载一样,图像需要一些时间才能显示出来。
.html 文件
<owl-carousel [options]="myCarouselOptions" [items]="myList">
<app-info-card class="item" *ngFor="let item of myList" [item]="item"></app-info-card>
</owl-carousel>
信息卡文件
<div class="card">
<div class="card-body" *ngIf="">
// this is the image that it disappers when scrolling and redisplays after a while
<a href="javascript:void(0)" (click)="open()">
<img (click)="open()" class="card-img-top" [src]="item.image" Onerror="this.src=''" alt="No image">
</a>
</div>
ts文件
myCarouselOptions = {
items: 3,
loop: true,
margin: 10,
autoplay: false,
autoplayTimeout: 30000000,
autoplayHoverPause: false,
responsiveClass: true,
nav: true,
dots: false,
rtl: false,
responsive: {
0: {
items: 1,
nav: false,
dots: true,
},}}
ngOnInit() {
this.getmyList();
}
check() {
this.subscriptions.sink = this.itemsService
.getList()
.subscribe((response: any) => {
if (response) {
this.myList = response.data;
}
});
}
我注意到我正在显示 6 个项目,但猫头鹰轮播创建了 12 个项目,6 个项目具有克隆类
解决方案
推荐阅读
- r - 如何在R中获得没有南北的纬度
- pytorch - pytorch xla:Pad的操作数的元素类型不匹配
- javascript - 在javascript中删除多个对象键值
- excel - 动态添加 OLEObject。事件不会触发
- django - Django Auth - 取消哈希密码
- angular - 如何在 Typescript 的 appconstants 中存储验证规则
- android - Flutter:让 iFame 在 Android 设备上全屏显示
- python - 在运行 Node.js 运行时(甚至自定义运行时)的 gcloud App Engine 中安装 numpy。在本地运行良好,但在部署时出现错误
- javascript - 更改范围滑块的颜色
- node.js - 如何从firebase存储中获取文件路径并使用云功能从路径重新上传回来?