1.home.html
2.? home.ts
import { Component,ViewChild } from '@angular/core';
import { NavController,Slides } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild(Slides) slides: Slides;
index:number = 0;
constructor(public navCtrl: NavController) {
}
//添加active
goToSlide(index) {
this.slides.slideTo(index, 500);
this.addActive(index);
}
// 滑動切換
slideChanged() {
let currentIndex = this.slides.getActiveIndex();
console.log('Current index is', currentIndex);
this.addActive(currentIndex);
}
// 改變tab 顏色
addActive(index){
this.index = index;
console.log(index)
}
}
export class AppComponent { }
參考ionic3官方文檔:https://ionicframework.com/docs/api/components/slides/Slides/