Ionic 2 在 navCtrl 按下后保留侧面菜单图标 [英] Ionic 2 keep sidemenu icon after navCtrl push
问题描述
当我使用 navCtrl.push 导航到页面时,侧边菜单图标(汉堡包)丢失,并且出现后退图标而不是侧边菜单图标.
When I navigate to a page using navCtrl.push, sidemenu icon (hamburger) is lost, and back icon is appearing instead of the sidemenu icon.
我想要做的是保留侧边菜单图标(将其放在 ion-navbar 的右侧),并且在将页面推送到 navCtrl 时,同时具有后退按钮和侧边菜单图标.
What I want to do, is to keep the sidemenu icon (put it on the right side of the ion-navbar), and when pushing a page to navCtrl, have both back button and sidemenu icon.
我在所有页面中都使用了这段代码:
I use this piece of code in all pages:
<ion-header>
<ion-navbar>
<button ion-button menuToggle right>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Post Offices</ion-title>
</ion-navbar>
</ion-header>
我使用:
this.navCtrl.push(Page)
它工作正常(虽然我失去了菜单图标,但没有其他问题).
And it works fine (I lose the menu icon though, but there is no other problem).
推荐答案
你需要将属性persistent="true"
添加到menuToggle
按钮将在所有视图上可用.您可以在 docs
You need to add attribute persistent="true"
to <ion-menu>
then menuToggle
button will be available on all views. You can find more details here in the docs
这篇关于Ionic 2 在 navCtrl 按下后保留侧面菜单图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!