Ionic 2 Slides 组件 - 如何访问 Swiper API [英] Ionic 2 Slides Component - How to Access Swiper API
本文介绍了Ionic 2 Slides 组件 - 如何访问 Swiper API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在应用欢迎页面/幻灯片上使用 ion-slides 组件(4 张幻灯片).我需要用户跳到最后一张幻灯片的能力.文档说 Swiper API 的 ion-slides 实现.我需要访问以下方法: 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 Slides 组件 - 如何访问 Swiper API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文