主页上的选项卡

时间:2018-04-26 09:44:09

标签: ionic-framework

我试图在我的主页中制作标签,但是当我将主页作为选项卡中的选定索引时,页面没有加载,这是我的代码:

home.ts:

...
export class HomePage {
  public isConnected: Boolean= true;

  homeRoot = HomePage;
  aRoot = SigninPage;
  bRoot = SignupPage;
...

home.html的:

///SOME CONTENT
<ion-tabs selectedIndex="0" *ngIf="isConnected">
                <ion-tab [root]="homeRoot" tabTitle="Home"></ion-tab>
                <ion-tab [root]="aRoot" tabTitle="Home"></ion-tab>
                <ion-tab [root]="bRoot" tabTitle="Home"></ion-tab>

            </ion-tabs>

app.compenents.ts:

//IMPORTS

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = HomePage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}

1 个答案:

答案 0 :(得分:0)

创建新页面TabsPage。

// Tabs.ts

export class TabsPage{
public isConnected: Boolean= true;

homeRoot = HomePage;
aRoot = SigninPage;
bRoot = SignupPage;

// Tabs.html

 <ion-tabs selectedIndex="0" *ngIf="isConnected">
            <ion-tab [root]="homeRoot" tabTitle="Home"></ion-tab>
            <ion-tab [root]="aRoot" tabTitle="Home"></ion-tab>
            <ion-tab [root]="bRoot" tabTitle="Home"></ion-tab>

  </ion-tabs>

// app.component.ts

 //IMPORTS
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = TabsPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: 
SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}