无法在 Ionic 中显示菜单按钮代替后退按钮

Not able to show the menu button in place of back button in Ionic

我正在开发 Ionic 应用程序,并且在我的 ionic 应用程序中使用了导航栏。当我移动到其他页面时,它代替菜单按钮显示后退按钮。我不想显示后退按钮,我总是想在导航栏中显示菜单按钮。

这是page1.html:

<ion-header>
  <ion-navbar hideBackButton="true">
    <button ion-button menuToggle start>
      <ion-icon name="menu"></ion-icon>
    </button>
  </ion-navbar>
</ion-header>

只是隐藏了后退按钮,没有显示菜单按钮。我想显示菜单按钮代替后退按钮。

这是page1.html:再试一次。

<ion-header>
  <ion-navbar swipeBackEnabled="false">
    <button ion-button menuToggle start>
      <ion-icon name="menu"></ion-icon>
    </button>
  </ion-navbar>
</ion-header>

这是行不通的。在这种情况下,它显示后退按钮。

这是page1.ts:

 ionViewWillEnter() {
  // Reset the content nav to have just this page
  // we wouldn't want the back button to show in this scenario
  this.navCtrl.setRoot(MerchandisePage);
 }

所以我决定将该页面作为根页面,但它一直在加载。这不起作用。

这是我的page.html:

<button (click)="merchandisepage2()" class="mybtn22" ion-button round>View All</button>

在这个页面中,我有一个按钮可以推送到另一个页面。

这是我的page.ts

 movetopage1()
{
    this.navCtrl.push(Page1);
}

我不想显示后退按钮,它应该始终在导航栏中显示菜单按钮。非常感谢任何帮助。

解决方法是,将页面设置为根页面。

page.ts:

movetopage1()
{
    this.navCtrl.setRoot(Page1);
}

这是 Ionic 侧边栏主题中的方法。

这是 Ionic 侧边栏主题中的主题

 openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }

当您在导航栏中有一个自定义按钮并且页面不是 root 时,ionic 会出现问题。

您可以在此处找到快速解决方案..

Ionic 3: Menutoggle keeps getting hidden