问题
如果遵循结构,我们会收到错误cannot find module
。
应用程序路由.module.ts
const routes: Routes = [
{
path: CHILD_MANAGEMENT_PORTAL.baseUrl,
canActivate: [AuthGuard],
component: EnvelopeComponent,
loadChildren: () =>
import('./features/child-management/child-management.module').then(
m => m.ChildManagementModule
),
data: {
menuResolver: ChildManagementMenuResolver,
pageTitleResolver: ChildManagementPageTitleResolver,
portalData: CHILD_MANAGEMENT_PORTAL
}
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
child-management-routing.module.ts:错误
const routes: Routes = [
{
path: 'dashboard',
loadChildren: './dashboard/child-dashboard.module#ChildDashboardModule'
},
{
path: '**',
redirectTo: 'dashboard'
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: []
})
export class SalesArrangementManagementRoutingModule {}
我们可以通过将子 routing.module 的 loadChildren 从 更改为 来解决这个loadChildren: './hoge.module#HogeModule'
错误loadChildren: () => import('./hoge.module.ts).then(m => m.HogeModule)'
。
child-management-routing.module.ts :正确
const routes: Routes = [
{
path: 'dashboard',
loadChildren: () => import('./dashboard/child-dashboard.module').then(m => m.ChildDashboardModule)
},
{
path: '**',
redirectTo: 'dashboard'
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: []
})
export class SalesArrangementManagementRoutingModule {}
但我不明白为什么。(我没有改变 app-routing.module.ts...)
那你能解释一下区别吗?