Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 从ionic 2的侧面导航菜单转换应用程序页面时,“后退”按钮不可用_Ionic Framework_Navigation Drawer_Back Button_Android Side Navigation - Fatal编程技术网

Ionic framework 从ionic 2的侧面导航菜单转换应用程序页面时,“后退”按钮不可用

Ionic framework 从ionic 2的侧面导航菜单转换应用程序页面时,“后退”按钮不可用,ionic-framework,navigation-drawer,back-button,android-side-navigation,Ionic Framework,Navigation Drawer,Back Button,Android Side Navigation,我正在开发一个ionic 2移动应用程序,我发现当我通过侧导航面板访问一个页面时,它没有在特定页面上提供自动生成的后退按钮,而当我以正常遍历形式逐页访问该页面时,该页面可以使用后退按钮。如何从侧导航面板菜单中获取后退按钮,请提出建议 仪表板 如果您在创建项目时创建了侧菜单应用程序,您可以在app.component.ts constructor(public platform: Platform, public statusBar: StatusBar, public splashScree

我正在开发一个ionic 2移动应用程序,我发现当我通过侧导航面板访问一个页面时,它没有在特定页面上提供自动生成的后退按钮,而当我以正常遍历形式逐页访问该页面时,该页面可以使用后退按钮。如何从侧导航面板菜单中获取后退按钮,请提出建议


仪表板

如果您在创建项目时创建了侧菜单应用程序,您可以在app.component.ts

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

    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Home', component: Createpage}
    ];

  }

  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();
    });
  }

  openPage(page) {
    // Reset the content nav to have just this page
    this.nav.setRoot(page.component);
  }
正如您在openPage函数中所看到的,它将页面组件设置为root,因此您不能看到back按钮,而是看到hamburger图标,它打开了侧菜单

现在

如果您仍然希望使用“后退”按钮从侧菜单打开页面,您可以这样做

openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    if(page.component == HomePage){
      this.nav.setRoot(HomePage);
    } else {
      this.nav.push(page.component);
    }
  }
在上面的代码中,您检查它是否是backbutton组件(您希望使用back按钮打开),如果是真的,您可以将其设置为push,而不是setRoot


有关更多说明的注释

请显示代码。使用“侧导航面板”导航时,您的ts代码看起来如何?