Angular 默认路由器 socket

标签 angular path default router outlet

我有用户模块,我正在尝试加载默认路由器 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/

相关文章:

javascript - Angular/Firebase - 从 Firebase 返回键和值

angular - 如何在 ionic 3 中包含 JS 文件

javascript - 更改检测不适用于文件上传

c++ - 为什么 CFileDialog::GetNextPathName 在文件路径很长时不起作用?

Windows 7 PATH 环境变量扩展

android - 读取存储在内存中的 pdf(文件路径无效)

c++ - 为什么在同一个类上使用不同的(shared_ptr 和普通)指针构造函数会得到不同的结果?

java - 默认情况下,如何为特定实体打开 hibernate 过滤器?

Angular Material 表单字段标签字体颜色和大小

html - 博主的随机默认缩略图