我们有一个角10应用程序,延迟加载在本地主机上工作。
但是,当使用命令“ng build”进行构建时,不会生成延迟加载模块。
这些是路由模块:
App-routing.modules.ts
//Imports
const routes: Routes = [
{
path: '',
loadChildren: () => import('./front-office/front-office-routing.module').then(m => m.FrontOfficeRoutingModule)
},
{ path: 'andex/back/login', component: LoginComponent },
{
path: 'andex/back',
loadChildren: () => import('./back-office/back-office-routing.module').then(m => m.BackOfficeRoutingModule),
canActivate: [AuthGuard]
},
{ path: '**', redirectTo:'/NotFound' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }Front-office-routing.module.ts
//Imports
const routes: Routes = [
{
path: '',
loadChildren: () => import('./entreprise/entreprise-routing.module')
.then(m => m.EntrepriseRoutingModule)
},
{
path: ':category',
loadChildren: () => import('./entreprise/entreprise-routing.module')
.then(m => m.EntrepriseRoutingModule)
},
{
path: ':category/:page',
loadChildren: () => import('./entreprise/entreprise-routing.module')
.then(m => m.EntrepriseRoutingModule)
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FrontOfficeRoutingModule { }Back-office-routing.module.ts
//Imports
const routes: Routes = [
{ path: '', component: DashboardComponent },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'vueensemble', component: VueensembleComponent },
{ path: 'modifutilisateur', component: ModifUtilisateurComponent },
{ path: 'modifpwd', component: ModifpwdComponent },
{ path: 'utilisateur', component: UtilisateurComponent },
{ path: 'parametres', component: ParametresComponent },
{
path: 'pages',
loadChildren: () => import('./pages/pages-routing.module').then(m => m.PagesRoutingModule)
},
{
path: 'articles',
loadChildren: () => import('./articles/articles-routing.module').then(m => m.ArticlesRoutingModule)
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BackOfficeRoutingModule { }谢谢。
发布于 2022-09-22 06:39:36
您应该在loadChildren中导入模块
import('./front-office/front-office.module')不是路由模块
import('./front-office/front-office-routing.module')https://stackoverflow.com/questions/73785026
复制相似问题