gpt4 book ai didi

Angular 5 空错误 : no elements in sequence while making child routes

转载 作者:太空狗 更新时间:2023-10-29 17:22:47 28 4
gpt4 key购买 nike

当我在路由中使用子项时,我无法从登录页面导航到仪表板页面,如下所示:

const appRoutes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent,pathMatch: 'full' },
{
path: 'dashboard',pathMatch: 'full', /* canActivate: [AuthGuard], */ component: DashboardComponent ,
children: [
{
path: 'online-submission/:moduleName',pathMatch: 'full', component: OnlineSubmissionComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "online-submission"
} ,
children: [
{ path: 'batch-upload-members',pathMatch: 'full', component: BatchUploadMembersComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "batch-upload-members"
} },
{ path: 'select-members',pathMatch: 'full', component: SelectMembersComponent,
/* canActivate: [AuthGuard], */data:{
breadcrumb: "select-members"
}
}
]
}
]
},
{ path: '**', component: PageNotFoundComponent }

];

然而,当我从路由中删除子属性并使它们成为兄弟路由时,路由工作正常。制作子路线时出现什么问题?我正在使用 cli 1.6.0-rc.1

到目前为止我尝试了什么?

  1. 评论 AuthGuard 不起作用,所以问题不在于那部分

  2. 我已经证实只有当我将它们作为子路由(制作面包屑时需要)时才会出现此问题。如果所有路由都是兄弟路由,则路由正常工作

  3. 在我找到 NavigationStart(id: 4, url: '/dashboard') 的 RouterModule.forRoot 中使用了 {enableTracing:true} 这似乎是 DashboardComponent 的正确 url

  4. 在 SO 上搜索了类似标题的问题,但没有一个解决了相同的问题:

Angular 2.0.1 Router EmptyError: no elements in sequence

Angular2 routing issues - Zone aware error No elements in sequence

Angular 2.0.1 Router EmptyError: no elements in sequence

最佳答案

这个错误是由于 Angular 的路由器的最新版本造成的。请删除还原回 Angular 版本或添加 pathMatch: 'full' 到您的路线。

export const userRoutes = [
{ path: 'profile', component: ProfileComponent, pathMatch: 'full' },
{ path: 'login', component: LoginComponent, pathMatch: 'full' }
];


export const appRoutes = [
{ path: '', redirectTo: '/events', pathMatch: 'full' },
{ path: 'user', loadChildren: './user/user.module#UserModule' }
];

可以找到issue here

关于 Angular 5 空错误 : no elements in sequence while making child routes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47614771/

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