这是我的应用设置:
这是我的 app-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SoftwareComponent } from './components/software/software.component';
const routes: Routes = [
{
path: '',
outlet: 'main',
component: SoftwareComponent,
children: [
{
path: 'personal',
children: [
{
path: '',
loadChildren: './components/software/data/personal/personal.module#PersonalModule'
}
]
}
]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {enableTracing: true})],
exports: [RouterModule]
})
export class AppRoutingModule { }
我的错误是:
错误错误:未捕获(承诺):错误:无法匹配任何路由。网址段:“个人” 错误:无法匹配任何路线。网址段:“个人”
也许有人可以告诉我我的设置有什么问题吗?
答案 0 :(得分:1)
将personal
移动到与第一个''
相同的级别。
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'personal'
},
{
path: 'personal',
outlet: 'main',
component: SoftwareComponent,
children: [
{
path: '',
loadChildren: './components/software/data/personal/personal.module#PersonalModule'
},
{
path: '',
loadChildren: './components/software/header/header-personal/header-personal.module#HeaderPersonalModule'
}
]
}
}
];