首页 文章

Ionic 3 - 不要在导航栏中将主页按钮更改为后退按钮

提问于
浏览
1

我有类似的东西:

在我的导航栏中,我有一个用于切换菜单的主页按钮 .

问题是,当导航堆栈超过1页时,离子会自动将其从主页按钮更改为后退按钮 .

I need the button to always remain a home button that toggles the menu, regardless of how many pages there are in the nav stack.

<ion-header>

  <ion-navbar>

        <button ion-button menuToggle>
          <ion-icon name="home"></ion-icon>
        </button>

    <ion-navbar>

</ion-header>

解决方案对我的案例不利:

1)如果我在更改页面时使用“setRoot”而不是“push”,则不会发生这种情况,因为导航堆栈总是有1页 .

然而,这对我来说不是一个选项,我想继续使用“推”并让按钮保持一个切换菜单的主页按钮,而不是更改为返回1页的后退按钮 .

2)设置hideBackButton =“false”完全隐藏后退按钮,但这并不意味着显示主页按钮,也不显示 .

<ion-navbar hideBackButton="false">

1 回答

  • 1

    使用ion-toolbar而不是ion-navbar:

    <ion-header>
      <ion-toolbar>
            <button ion-button menuToggle>
              <ion-icon name="home"></ion-icon>
            </button>
        <ion-toolbar>
    </ion-header>
    

相关问题