我正在尝试创建一个像这样的轮播,我可以使用此包装器来使用swiper库(https://github.com/ksachdeva/angular2-swiper)
但这有可能通过使用纯ionic2及其ion-slides
组件来实现我的目标。与添加另一个可能不必要的模块相比,我更愿意这样做。不幸的是,文档尚不清楚。
swiper已直接集成到Ionic2中...不知道这里的问题是什么?
或者您可以通过这种方式来实现Ionic 2幻灯片组件-如何访问Swiper API
import { NavController } from 'ionic-angular/index';
import { Component, ViewChild } from "@angular/core";
@Component({
template:`
<ion-content class="has-header">
<ion-slides [options]="_options" #mySlider>
<ion-slide *ngFor="let testSlide of testSlides">
<img src="http://placehold.it/150x150">
</ion-slide>
</ion-slides>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</ion-content>
`
})
export class HomePage {
greeting: string;
testSlides: string[] = [];
@ViewChild('mySlider') mySlider: any;
constructor(private nav: NavController) {
this._options = {
slidesPerView:3,
pager: true,
nextButton: ".swiper-button-next",
prevButton: ".swiper-button-prev",
onInit:()=>{
}
}
setTimeout(()=>{
for (var i=1; i<6; i++) {
this.testSlides.push("Slide - "+i);
}
},100);
}
}
The Plunkr- http ://plnkr.co/edit/ybmDsYICQopis88vDl37?p=preview
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句