首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用ng build的角度延迟加载

问不使用ng build的角度延迟加载
EN

Stack Overflow用户
提问于 2022-09-20 10:08:56
回答 1查看 51关注 0票数 0

我们有一个角10应用程序,延迟加载在本地主机上工作。

但是,当使用命令“ng build”进行构建时,不会生成延迟加载模块。

这些是路由模块:

App-routing.modules.ts

代码语言:javascript
复制
//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

代码语言:javascript
复制
//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

代码语言:javascript
复制
//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 { }

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-09-22 06:39:36

您应该在loadChildren中导入模块

代码语言:javascript
复制
import('./front-office/front-office.module')

不是路由模块

代码语言:javascript
复制
import('./front-office/front-office-routing.module')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73785026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档