我正在使用 Ionic CLI v3.5.0 和 Ionic2 Super Tabs v3.0.2 但选项卡显示不正确。单击选项卡时,页面会更改,但不会显示。
这是我的 app.module.ts。如文档中所示,我已添加 SuperTabsModule.forRoot()。
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { SuperTabsController} from 'ionic2-super-tabs';
import { MyApp } from './app.component';
import { ExplorePage } from '../pages/explore/explore';
import { SuperTabsModule } from 'ionic2-super-tabs';
import { CoachingsPage } from '../pages/coachings/coachings';
import { TutorsPage } from '../pages/tutors/tutors';
@NgModule({
declarations: [
MyApp,
ExplorePage,
CoachingsPage,
TutorsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
SuperTabsModule.forRoot(),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
ExplorePage,
CoachingsPage,
TutorsPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
这是我的 tab.ts 文件。这里我的页面没有使用延迟加载,所以我没有在这里添加 SuperTabsModule。我已经添加了它,但是没有用。
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { CoachingsPage } from '../coachings/coachings';
import { TutorsPage } from '../tutors/tutors';
/**
* Generated class for the ExplorePage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-explore',
templateUrl: 'explore.html',
})
export class ExplorePage {
tab1Root:any = CoachingsPage;
tab2Root:any = TutorsPage;
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad ExplorePage');
}
}
这是 tabs.html 文件:
<super-tabs>
<super-tab [root]="tab1Root" title="Top Tutors"></super-tab>
<super-tab [root]="tab2Root" title="Top Coaching"></super-tab>
</super-tabs>