gpt4 book ai didi

angular - 如何在ionic-4中设置默认登录页面和登录后打开选项卡

转载 作者:行者123 更新时间:2023-12-03 21:20:22 24 4
gpt4 key购买 nike

我正在创建 ionic tabs 项目,我想在打开 tabs 之后设置默认登录页面。我设置在默认登录页面,但登录后我没有在 ionic 4 中获得标签。请帮助我如何解决这个问题....?

tabs.router.module.ts

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

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

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

app-routing.module.ts

    import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'tabs/tab1', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'login', loadChildren: './login/login.module#LoginPageModule' },
{ path: 'register', loadChildren: './register/register.module#RegisterPageModule' }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}

我正在更改路线但没有获得标签请帮助我如何添加路线以在登录后打开标签。

最佳答案

这应该可行。

tabs.router.module.ts

...
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'tab1',
children: [
{ path: '', loadChildren: '../tab1/tab1.module#Tab1PageModule'}
]
},
...
{ path: '', redirectTo: '/start/tabs/tab1', pathMatch: 'full'}
]
}
];
...

app-routing.module.ts

...
const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'start', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'login', loadChildren: './login/login.module#LoginPageModule' },
];
...

关于angular - 如何在ionic-4中设置默认登录页面和登录后打开选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54666533/

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