我正在尝试将路由重定向到空的某个路径。但是在第一种情况下,它获得正确的路径,但是在尝试再次重定向时抛出404。
在面包屑中,在单击“父级”时正确地重定向,路由将为“ / parent / child / child1”,在单击“子级1”时再次正常,但是在单击“父级”时出现问题路由“ / parent / child”,但应该是“ / parent / child / child1”路由,不知道我在这里缺少什么。 我尝试为其提供完整路径(即),但仍然是相同的问题{path:”,redirectTo:'/ parent / child / child1',pathMatch:'full'},
// App routing module
export const App_Route: Routes = [
{ path: 'parent',
data: {pageTitle: 'Parent'},
loadChildren:'./modules/parent/parent.module#ParentModule'},
]
// Parent module routing
export const Parent_Route: Routes = [
{ path: '', redirectTo: 'child/child1', pathMatch: 'full' },
{
path: '',
component: rootWrapper,
children: [
{
path: 'child',
data: {pageTitle: 'Child Component'},
loadChildren:'./child/child.module#ChildModule'
},
]
// Child module routing
export Child_Route: Routes = [
{path: '', redirectTo: 'child1', pathMatch: 'full'},
{
path: '',
component: rootWrapper,
children: [
{ path: 'child1',
component: Child1COmponent,
data: {
pageTitle: 'Child 1',
authorities: ['ROLE_ADMIN'],
}]}]
实际:抛出404错误。 预期:应重定向到/ parent / child / child1
答案 0 :(得分:0)
尝试在路由代码中进行以下指定的修改:
export const Parent_Route: Routes = [
{ path: '', redirectTo: 'child/child1', pathMatch: 'full' },
{
path: 'child',
component: rootWrapper,
children: [
{
path: '',
data: {pageTitle: 'Child Component'},
loadChildren:'./child/child.module#ChildModule'
},
]
// Child module routing
export Child_Route: Routes = [
{path: '', redirectTo: 'child1', pathMatch: 'full'},
{
path: 'child1',
component: rootWrapper,
children: [
{ path: '',
component: Child1COmponent,
data: {
pageTitle: 'Child 1',
authorities: ['ROLE_ADMIN'],
}]}]