简体   繁体   English

基于Ionic 4选项卡的应用程序中的多个侧面菜单

[英]Multiple side menus in Ionic 4 tab based app

I've created a tabs based app with the command. 我已经使用命令创建了一个基于标签的应用。

ionic start myApp tabs

The idea is to add different side menus for each tab pages, trying to do a master detail navigation, using the side menu as master elements list and the tab pages to show detailed content. 想法是为每个选项卡页面添加不同的侧菜单,尝试进行主细节导航,使用侧菜单作为主元素列表,并使用选项卡页面显示详细内容。

The app.component.html file looks like this: app.component.html文件如下所示:

<ion-app>
  <ion-router-outlet></ion-router-outlet>
</ion-app>

tab1.page.html like code: tab1.page.html类似代码:

<ion-menu contentId="aside1" side="start">
    <ion-content>
        <ion-list>
            <ion-item class="side-menu-item" *ngFor="let item of strings">{{item.title}}</ion-item>
        </ion-list>
    </ion-content>
</ion-menu>
<ion-router-outlet id="aside1" main></ion-router-outlet>

tab2.page.html code: tab2.page.html代码:

<ion-menu contentId="aside2" side="start">
    <ion-content>
        <ion-list>
            <ion-item class="side-menu-item" *ngFor="let item of strings">{{item.title}}</ion-item>
        </ion-list>
    </ion-content>
</ion-menu>
<ion-router-outlet id="aside2" main></ion-router-outlet>

Both menus aside1 and aside2 works when I swipe and show the individual strings array elements at the first look of tabs. 当我滑动并在选项卡的第一次显示时显示单个字符串数组元素时,菜单aside1aside2可以使用。 The problem is when I go back to previous tab, instead of show again aside1 side menu , this stop working and what the swipe gesture really does is show the side menu of the other tab. 问题是当我返回上一个选项卡时,而不是再次显示aside1 side menu ,此操作停止了,而swipe手势的真正作用是显示了另一个选项卡的侧菜单。

I don't know if I need a particular code in tab1.page.ts and tab2.page.ts to make this work. 我不知道是否需要在tab1.page.tstab2.page.ts使用特定的代码才能完成此工作。

The problem was that I haven't specify the menuId in each side menu. 问题是我没有在每个侧面菜单中指定menuId

I do not delete the question in case someone finds it interesting to create different menus for each page 如果有人发现为每个页面创建不同的菜单很有趣,我不会删除该问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM