gpt4 book ai didi

javascript - Ionic 选项卡不会转到下一页

转载 作者:行者123 更新时间:2023-11-29 05:38:15 26 4
gpt4 key购买 nike

我有一个底部带有选项卡的 ionic 应用程序项目,我正在尝试创建一个新选项卡来链接到我制作的新页面,当我执行正确的代码时,按下后它不会转到该页面新制作的选项卡按钮我联系了 ionic 支持,他们说它看起来不错,但他们无法进一步帮助我

这是我的 ionic 标签代码

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

import { FormsPage } from 'forms.page'

const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'tab1',
children: [
{
path: '',
loadChildren: '../tab1/tab1.module#Tab1PageModule'
}
]
},
{
path: 'parties',
children: [
{
path: '',
loadChildren: '../tab2/tab2.module#Tab2PageModule'
}
]
},
{
path: 'tab3',
children: [
{
path: '',
loadChildren: '../tab3/tab3.module#Tab3PageModule'
}
]
},
{
path: '',
redirectTo: '/tabs/tab1',
pathMatch: 'full'
}
]
},
{
path: 'forms',
children: [
{
path: '',
loadChildren: '../forms/forms.module#FormsPageModule'
}
]

},
{
path: '',
redirectTo: '/tabs/tab1',
pathMatch: 'full'
}

];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}

<ion-tabs>

<ion-tab-bar slot="bottom">
<ion-tab-button tab="tab1">
<ion-icon name="flash"></ion-icon>
<ion-label>Tab One</ion-label>
</ion-tab-button>

<ion-tab-button tab="parties">
<ion-icon name="apps"></ion-icon>
<ion-label>Tab Two</ion-label>
</ion-tab-button>

<ion-tab-button tab="tab3">
<ion-icon name="send"></ion-icon>
<ion-label>Tab Three</ion-label>
</ion-tab-button>

<ion-tab-button tab="forms">
<ion-icon name="clipboard"></ion-icon>
<ion-label>Forms</ion-label>
</ion-tab-button>

</ion-tab-bar>

</ion-tabs>

最佳答案

尝试使用此配置。

  const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'tab1',
loadChildren: '../tab1/tab1.module#Tab1PageModule'
},
{
path: 'parties',
loadChildren: '../tab2/tab2.module#Tab2PageModule'
},
{
path: 'tab3',
loadChildren: '../tab3/tab3.module#Tab3PageModule'
}
]
},
{
path: 'forms',
children: [
{
path: '',
loadChildren: '../forms/forms.module#FormsPageModule'
}
]

},
{
path: '',
redirectTo: '/tabs/tab1'
}

];

并在所有 child 中确保有这个路由:

  const routes: Routes = [
{
path: '',
component: Tab1Page
}
];

这适用于选项卡中的每个子页面。

关于javascript - Ionic 选项卡不会转到下一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56813130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com