Angular 4 - 使用 children 的路由不起作用
Angular 4 - Route with children doesn't work
您好,我有以下路线结构:
export const routes: Routes = [
{
path: 'site', component: MainViewComponent, pathMatch: 'full',
children: [
{ path: '', redirectTo: 'extra-details', pathMatch: 'full'},
{ path: 'extra-details', component: ExtraDetailsViewComponent}
]},
{ path: 'login', component: LoginViewComponent, pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
登录和 404(未找到页面)都运行良好,问题是当我尝试访问 /site 时它被重定向到 /site/extra-details 但它显示 404 视图。当我评论“**”路径时出现以下错误:
Error: Cannot match any routes. URL Segment: 'site/extra-details'
我错过了什么?
谢谢,
马坦
pathMatch
仅在重定向时需要,在定义组件的地方将其删除。
您好,我有以下路线结构:
export const routes: Routes = [
{
path: 'site', component: MainViewComponent, pathMatch: 'full',
children: [
{ path: '', redirectTo: 'extra-details', pathMatch: 'full'},
{ path: 'extra-details', component: ExtraDetailsViewComponent}
]},
{ path: 'login', component: LoginViewComponent, pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
登录和 404(未找到页面)都运行良好,问题是当我尝试访问 /site 时它被重定向到 /site/extra-details 但它显示 404 视图。当我评论“**”路径时出现以下错误:
Error: Cannot match any routes. URL Segment: 'site/extra-details'
我错过了什么?
谢谢, 马坦
pathMatch
仅在重定向时需要,在定义组件的地方将其删除。