Angular 7:为什么延迟加载编译不生成块?

问题描述

在我的应用程序中,延迟加载在Angular 4中可以完美地工作。但是,当我迁移到Angular 7之后,使用ng serve时,惰性加载和路由已停止工作。

app.module.ts中定义应用程序的路由,如下所示:

            RouterModule.forRoot([
              { path: 'info/:gitCode/:pemCode/:getRtComponent',component: RedComponent },{ path: 'info/:gitCode/:pemCode/:getFaq/:getRtComponent',{ path: 'loadGuardsInfo/:gitCode/:pemCode/:getRtComponent',{ path: 'loadGuardsInfo/:getRtComponent',{ path: 'recDet',component: RecDetComponent },{ path: 'SlaveComponent/:pfScreen',loadChildren: './ally/slave/slave.module#SlaveModule' },{ path: 'MasterComponent/:pfScreen',loadChildren: './ally/master/master.module#MasterModule' },{ path: 'DashedComponent/:pfScreen',loadChildren: './ally/dashed/dashed.module#DashedModule' }
              ])
          ],providers: [ReqService,{ provide: APP_BASE_HREF,useValue: './' },{
            provide: ErrorHandler,useClass: GlobalErrorHandler
          },{ provide: LocationStrategy,useClass: HashLocationStrategy }],bootstrap: [AppComponent],exports: []

我在互联网上浏览了很多文章,并尝试了很多方法,但是都没有用。

当我第一次尝试服务时,我只得到6个块:main.js,polyfills.js,runtime.js,scripts.js,styles.js and vendor.js以及各种打字稿错误(由于打字稿已从2.4更新到3.1,并且根据在我看来,他们是可以预期的并且可以解决)。奇怪的是:当我现在转到app.module.ts时,提到了我的路线,然后尝试:通过使用退格键引入一些空白字符来进行CONTROL + S,然后所有延迟加载的命名块开始显示在终端中。

另外,每个延迟加载的模块都在其中建立了路由(例如SlaveModule):

 RouterModule.forChild([
  {path:'',component:SlaveComponent}
 ])

升级之前:

enter image description here

升级后:

enter image description here

这里的角度专家能告诉我发生了什么问题以及如何解决这些问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)