Ionic 2幻灯片组件 - 如何访问Swiper API [英] Ionic 2 Slides Component - How to Access Swiper API
本文介绍了Ionic 2幻灯片组件 - 如何访问Swiper API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在app欢迎页面/幻灯片上使用ion-slides组件(4张幻灯片)。我需要能够让用户跳到最后一张幻灯片。 Docs表示 Swiper API 的离子幻灯片实现。我需要访问以下方法: mySwiper.slideTo(index,speed,runCallbacks);
Using ion-slides component (4 slides) on app welcome page/slides. I need ability for user to skip to last slide. Docs say ion-slides implementation of Swiper API. I need to access methods like: mySwiper.slideTo(index, speed, runCallbacks);
如何获取提示实现?
推荐答案
您可以在options属性中传递一个函数。
You can pass a function within the options property.
原始答案。
@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);
}
}
如需更多选项,请查看 swiper api 。
For further options have a look at the swiper api.
这篇关于Ionic 2幻灯片组件 - 如何访问Swiper API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文