为什么nav.push在app组件页面上无法正常工作?

时间:2017-06-29 10:22:08

标签: ionic-framework

我使用sidemenu --v2模板作为我的app的基础,它在app.component / app.html页面中有sidemenu。我只是尝试nav.push堆栈中的其他页面,在ListPage下面的示例中。

然而,它导致一个带有后退按钮的页面无效 - 它会卡在新页面上。

这是我的 app.html

  <ion-content>
    <ion-list>
      <button menuClose ion-item (click)="pushPage(listPage)">List Page
      </button>
    </ion-list>
  </ion-content>

这是我的 app.component.ts

import { Component, ViewChild, } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = HomePage;
  public listPage = ListPage;

  constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
    this.initializeApp();

  }

  initializeApp() {
    this.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.
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }

  pushPage(page) {
    this.nav.push(page).then(response => {
        console.log(response);
    }).catch(e => {
        console.log(e);
    });
  }

}

编辑:问题只适用于android,ios工作正常。

0 个答案:

没有答案