动态默认选中tab问题
来源:

Yado666
2016-08-03
我按照老师写的代码,怎么都不会默认选中第二个。求解答。
<ion-tabs #myTabs> <ion-tab [root]="tab1Root" tabTitle="首页" tabIcon="home"></ion-tab> <ion-tab [root]="tab2Root" tabTitle="我们" tabIcon="aperture" ></ion-tab> <ion-tab [root]="tab3Root" tabTitle="好友" tabIcon="contacts"></ion-tab> </ion-tabs>
import {Component} from '@angular/core'; import {HomePage} from '../home/home'; import {AboutPage} from '../about/about'; import {ContactPage} from '../contact/contact'; import {Tabs} from 'ionic-angular'; import {Injectable,ViewChild} from '@angular/core'; @Component({ templateUrl: 'build/pages/tabs/tabs.html' }) export class TabsPage { @ViewChild('myTabs') tabRef: Tabs; private tab1Root: any; private tab2Root: any; private tab3Root: any; constructor() { // this tells the tabs component which Pages // should be each tab's root Page this.tab1Root = HomePage; this.tab2Root = AboutPage; this.tab3Root = ContactPage; } ionViewDidEnter(){ this.tabRef.select(1); } }
默认选中的还是第一个。版本是32.
写回答
3回答
-
你看一下第八章。
012016-08-04 -
cache_0003
2016-08-30
我也遇到了这个问题,我先去看看第八章差异吧,我以为是我出错了
00 -
Yado666
提问者
2016-08-03
实在没办法了,只能重新装了一个项目,代码也是一样的,就可以默认选中了。太奇怪了~
00
相似问题