我有用户模块,我正在尝试加载默认路由器 socket 。 我想在路径为/user 时加载 UserHomeComponent 但它不起作用。如果我添加一条路径而不是将其保留为空,它就可以正常工作。 这是我的用户路由模块:
const routes:Routes = [
{path: 'user' , component: UserComponent , children:[
{path: '' , component: UserHomeComponent},
{path: 'new-request' , component: NewRequestComponent},
{path: 'checkout' , component: CheckoutComponent},
{path: 'edit-info' , component: UserEditInfoComponent},
{path: 'requests', component: UserRequestsComponent},
{path: 'change-password' , component: UserChangePasswordComponent},
{path: 'delete-account' , component: DeleteAccountComponent}
]}
]
这是我的应用程序路由模块:
const appRoutes:Routes = [
{path: '' , redirectTo: 'login' , pathMatch: 'full'},
{path: 'login' , component: LoginComponent },
{path: 'signup' , component: SignupComponent},
{path: 'user' , loadChildren: () => import('./user/user.module').then(m => m.userModule)},];
最佳答案
要加载 UserHomeComponent,请更改此
{path: 'user' , component: UserComponent , children:[
由
{path: '' , component: UserComponent , children:[
关于Angular 默认路由器 socket ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60902786/