Tab选项卡滑动点击切换ionic3+angular4

2017-09-27  本文已影响0人  Allen6879

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/

上一篇下一篇

猜你喜欢

热点阅读