我在嵌套路线方面遇到了麻烦。这是我的情况:
路由:
RouterModule.forRoot([
{
path: 'workerevaluation', component: MainComponent, children: [
{
path: 'details/:code', component: EmployeeDetailComponent, children: [
{ path: '', component: EmployeeTableComponent },
{ path: 'evaldetail/:evalid', component: EmployeeEvaluationDetailComponent }
]
}
]
},
]),
在EmployeeTableComponent内部,我有一个带有(单击)的按钮,应该将我重定向到'evaldetail /:evailid',但会引发此错误:
错误错误:未捕获(已承诺):错误:无法匹配任何路由。 URL段:'https:/ localhost:44352 / workerevaluation / details / W002 / evaldetail / EVAL123'
似乎似乎无法识别'details /:code'子路径。
有任何建议吗?
我相信您的路由器配置应如下所示:-
RouterModule.forRoot([
{path: '', pathMatch: 'full', redirectTo: 'workerevaluation'},
{
path: 'workerevaluation', children: [
{
path: '',
component: MainComponent
},
{
path: 'details/:code', children: [
{ path: '', component: EmployeeTableComponent },
{ path: 'evaldetail/:evalid', component: EmployeeEvaluationDetailComponent }
]
}
]
},
])