当我在路由中使用子项时,我无法从登录页面导航到仪表板页面,如下所示:
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 }
Run Code Online (Sandbox Code Playgroud)
].
但是,当我从路由中删除子属性并使其兄弟姐妹路由工作正常.制作儿童路线时有什么问题?我正在使用cli 1.6.0-rc.1
到目前为止我尝试了什么?
评论AuthGuard没有用,所以问题不在于那个部分
我已经证实,只有当我将它们作为儿童路线(我需要制作面包屑)时才会出现这个问题.如果所有路由都是兄弟,则路由正常
用{enableTracing:true}在RouterModule.forRoot哪里,我觉得NavigationStart(id: 4, url: '/dashboard')这似乎对DashboardComponent正确的URL
在SO上搜索类似的标题问题,但没有一个解决同一问题:
Nas*_*din 13
此错误是由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' }
];
Run Code Online (Sandbox Code Playgroud)
你可以在这里找到问题
| 归档时间: |
|
| 查看次数: |
2979 次 |
| 最近记录: |