Ionic 2幻灯片组件 - 如何访问Swiper API

Ste*_*ick 9 ionic-framework ionic2

在app欢迎页面/幻灯片上使用离子滑动组件(4张幻灯片).我需要能够让用户跳到最后一张幻灯片.Docs说,离子幻灯片实现了Swiper API.我需要访问以下方法:mySwiper.slideTo(index, speed, runCallbacks);

关于如何实施的提示?

Flo*_*low 8

您可以在options属性中传递函数.

原始答案.

@Component({
  selector: 'my-component',
  template: '<ion-slides [options]="options">
               <ion-slide>Slide1</ion-slide>
               <ion-slide>Slide2</ion-slide>
             </ion-slides>',
  directive: [IONIC_DIRECTIVES]
})
export class MyComponent {
  public slider: any;

  constructor() {
    this.options = {
      onlyExternal: false,
      onInit: (slides: any) =>
        this.slider = slides
    }
  }

  click() {
    this.slider.sliderNext(true, 250);
  }
}
Run Code Online (Sandbox Code Playgroud)

有关更多选项,请查看swiper api.