0

我正在构建具有多屏幕的 Angular7 应用程序。我使用延迟加载。无法弄清楚为什么延迟加载内部模块中没有显示屏幕。(网址已更改,但即使我将路由器插座放在父级中,组件也不会显示)

*********app.routing.module.ts*******

const routes: Routes = [

  {
    path: '', component: HomepageComponent, canActivate: [AuthGuard],
    children: [
      {
        path: 'search', component: SearchOutletComponent,
        loadChildren: './personal-info/personal.module#PersonalModule'
      },
      { path: "y", component: DateReport},
      { path: "test", component: TestReport},


    ],
  },
  {
    path: 'Login', children: [
      { path: '', component: LoginComponent }
    ]
  },
  { path: '**', redirectTo: 'Login' }

];



*********Personal.routing.module.ts*******

const routes: Routes = [

  {
    path: 'personal-info', component: PersonalInfoOutletComponent,
    children: [
      { path: '', component: PersonalInfoComponent },
      {
        path: 'fund',
        loadChildren: './fund-details/fund.module#FundlModule',
      },
    ]
  },
  { path: '', component: SearchComponent },

];


*******Fund Module*******

const routes: Routes = [
    { path: '', component: FundDetailsComponent }
];

@NgModule({
    declarations:
        [
            FundDetailsComponent
        ],
    imports: [
        SharedModule,
        CommonModule,
        PersonalModule,
        MaterialModule,
        RouterModule.forChild(routes)
    ],
    exports: [RouterModule],
    entryComponents: [UserDetailsComponent]
})
export class FundlModule { }

因此,当我尝试 Naivgete 到 localhost:4200/search/personal-info/fund << 我看到在 F12 中加载了延迟加载,并且 URL 已更改!但是基金的成分没有显示出来。相反,我得到了这条路线的组件“{路径:'',组件:搜索组件},”我无法弄清楚为什么?如果我删除这条路径,我会按预期获得正确的基金组成部分。

所有组件,例如

 SearchOutletComponent,PersonalInfoOutletComponent

have "<router-outlet></router-outlet>里面,所以他们显示他们的孩子。

4

0 回答 0