如何解决如何使用 ion-slides 在 ionic5 中获取当前活动幻灯片索引
在 TS 文件中:
async onSlideChange() {
const index = await this.slides.nativeElement.getActiveIndex();
console.log('@@@@index',index);
}
在 html 文件中:
`<ion-slides class="" [options]="sliderOption" (ionSlideDidChange)="onSlideChange()" #slides>
<ion-slide>
<ng-container>
<ion-label class="suggestion-label">
slide 1
</ion-label>
</ng-container>
</ion-slide>
<ion-slide>
<ng-container>
<ion-label >
slide2
</ion-label>
</ng-container>
</ion-slide>
<ion-slide>
<ng-container>
<ion-label >
slide3
</ion-label>
</ng-container>
</ion-slide>
<ion-slide>
<ng-container>
<ion-label >
slide4
</ion-label>
</ng-container>
</ion-slide>
<ion-slide>
<ng-container>
<ion-label>
slide5
</ion-label>
</ng-container>
</ion-slide>
</ion-slides>`
说明: 根据此代码,我只有 0 和 1 索引。但我有 5 张幻灯片。我想要带有循环选项的 3 个 div 和活动 div 的滚动条,以添加额外的 css。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。