[英]ionic tab view gone when clicking on a tab
I searched for the solution, but didn't find any match in this case.我搜索了解决方案,但在这种情况下没有找到任何匹配项。
I have created a page called "entertainment" and inside that I have created two other pages called "monthly" and "special" inside the entertainment folder.我创建了一个名为“娱乐”的页面,在该页面中,我在娱乐文件夹中创建了另外两个页面,分别称为“每月”和“特殊”。 FYI, the folder structure is look alike this.
仅供参考,文件夹结构看起来像这样。
The entertainment page's route look like as follows.娱乐页面的路线如下所示。
const routes: Routes = [
{
path: '',
component: EntertainmentPage
},
{
path: 'monthly',
loadChildren: () => import('./monthly/monthly.module').then( m => m.MonthlyPageModule)
},
{
path: 'special',
loadChildren: () => import('./special/special.module').then( m => m.SpecialPageModule)
}
];
Also the tab view looks like as follow.选项卡视图也如下所示。
<ion-tabs >
<ion-tab-bar slot="bottom" style="width: 100% !important;">
<ion-tab-button tab = 'monthly'>
<ion-icon name="fast-food"></ion-icon>
<ion-label>Food</ion-label>
</ion-tab-button>
<ion-tab-button tab = 'special'>
<ion-icon name="beer"></ion-icon>
<ion-label>Alcohol</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
But when I clicked on a given tab the page is loaded and the undelying tab is gone .但是,当我单击给定选项卡时,页面已加载,并且不存在的选项卡消失了。 Any suggestion on this please.
请对此提出任何建议。 Thanks in advance.
提前致谢。
Found the solution with the help of @Mostafa在@Mostafa的帮助下找到了解决方案
So what I just missed is, add each and every tab route as child route.所以我刚刚错过的是,将每个选项卡路由添加为子路由。
{
path: '',
component: EntertainmentPage,
children:[
{
path: '',
redirectTo: 'monthly',
pathMatch: 'full'
},
{
path: 'monthly',
loadChildren: () => import('./monthly/monthly.module').then( m => m.MonthlyPageModule)
},
{
path: 'special',
loadChildren: () => import('./special/special.module').then( m => m.SpecialPageModule)
},
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.