[英]Ionic Angular Application: How to show slide index using swiper?
can anyone tell me why the interpolation of the index property doesn't work?谁能告诉我为什么 index 属性的插值不起作用? the value remains fixed at 1.
该值保持固定为 1。
.html .html
<swiper (slideChange)="onSlideChange($event)">
<ng-template *ngFor ="let image of this.images, let i = index" swiperSlide>
<ion-list style="align-items:center">
<ion-img class="image" [src]="image.data"></ion-img>
<ion-label>{{image.name}}</ion-label>
</ion-list>
</ng-template>
</swiper>
<ion-label>{{index}}/{{this.images.length}}</ion-label>
.ts .ts
images = [....];
index = 1;
onSlideChange(event){
this.index = event[0].activeIndex+1;
console.log(this.index);
}
ps the console prints the correct index value every (slideChange) ps 控制台每隔(slideChange)打印正确的索引值
You Can use getActiveIndex() Read official documentation https://ionicframework.com/docs/v3/api/components/slides/Slides/#getActiveIndex您可以使用 getActiveIndex() 阅读官方文档https://ionicframework.com/docs/v3/api/components/slides/Slides/#getActiveIndex
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.