在离子2中使用带侧边菜单的nav.push [英] Use nav.push with side menu in ionic 2

查看:140
本文介绍了在离子2中使用带侧边菜单的nav.push的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 ionic2 中制作一个小应用程序来了解它,但我遇到导航问题。

I try to make a little app in ionic2 to learn about it but I have a problem with navigation.

事实上,我很清楚 rootpage 之间的区别(更改whit nav。 setRoot )和普通页面(添加 nav.push )。对于我的应用程序,我需要能够打开一个侧面菜单(如果我在一个 rootpage ,这是可以的,但不是第二个不行页面的类型)并且能够返回(这对推送页面没有问题,但是没有根页面)。

In fact I have well understand the difference between a rootpage (change whit nav.setRoot) and a "normal" page (add with nav.push). The thing is for my app I'll need to be able to open a side menu (this is ok if I'm on a rootpage but not it's not ok with the second type of page) and to be able to go back (this is ok with a push page but not with a rootpage).

所以对我来说,这种类型的页面应该是推送而不是根页面,但是如何在这种类型的页面上重复使用侧边菜单?

So for me this type of page should be push and not a root page but how repear side menu on this type of page?

谢谢。

推荐答案

编辑:

如何在 ion-menu <中使用 persistent =true / code>项目?就像你在Ionic2文档中看到的那样:

What about using persistent="true" in your ion-menu item? Like you can see in Ionic2 docs:


持久菜单持久菜单在
NavBar中显示所有页面上的MenuToggle按钮导航堆栈。要使菜单持久化
,请在元素上将持久性设置为true。请注意,
只影响附加到Menu
的NavBar中的MenuToggle按钮,持久设置为true,任何其他MenuToggle按钮都不会受
影响。

Persistent Menus Persistent menus display the MenuToggle button in the NavBar on all pages in the navigation stack. To make a menu persistent set persistent to true on the element. Note that this will only affect the MenuToggle button in the NavBar attached to the Menu with persistent set to true, any other MenuToggle buttons will not be affected.

所以你的 app.html 将会是:

<ion-menu [content]="content" persistent="true">

  <ion-toolbar>
    <ion-title>Pages</ion-title>
  </ion-toolbar>

  <ion-content>
    <ion-list>
      <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
        {{p.title}}
      </button>
      <button menuClose ion-item (click)="logout()">Logout</button>
    </ion-list>
  </ion-content>

</ion-menu>

<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

这篇关于在离子2中使用带侧边菜单的nav.push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆