Ionic 3图像滑块自动播放效果很好,但是当我手动滑动图像时,自动播放停止工作.以下是我的离子3代码.我真的被困在这里..
slideData = [{ image: "../../assets/img1.jpg" },{ image: "../../assets/img2.jpg" },{ image: "../../assets/img3.jpg" }]
HTML代码如下
<ion-slides class="slide-css" autoplay="100" loop="true" speed="100" pager="true" autoplayDisableOnInteraction = "false"> <ion-slide *ngFor="let slide of slideData"> <img src="{{slide.image}}" /> </ion-slide> </ion-slides>
更新:
你需要像这样使用它:
import { Component,ViewChild } from '@angular/core'; import { IonicPage,NavController,NavParams,Slides } from 'ionic-angular'; @ViewChild(Slides) slides: Slides; constructor(private navCtrl: NavController,private navParams: NavParams) { } ionViewDidEnter() { this.slides.autoplayDisableOnInteraction = false; }
注意:您需要在html页面上删除autoplayDisableOnInteraction =“false”.
旧答案:
您可以使用autoplayDisableOnInteraction =“false”,如下所示.
<ion-slides class="slide-css" autoplay="100" loop="true" speed="100" pager="true" autoplayDisableOnInteraction = "false"> </ion-slides>
See how it implements on Ionic
disableOnInteraction boolean true Set to false and autoplay will not be disabled after user interactions (swipes),it will be restarted every time after interaction