美文网首页
Tab选项卡滑动点击切换ionic3+angular4

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

作者: Allen6879 | 来源:发表于2017-09-27 15:29 被阅读0次

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/

相关文章

网友评论

      本文标题:Tab选项卡滑动点击切换ionic3+angular4

      本文链接:https://www.haomeiwen.com/subject/qxuuextx.html