我正在使用 angular 創(chuàng)建一個(gè)ui 庫。在工作區(qū)中,主 app 有一個(gè)項(xiàng)目,ui 庫有一個(gè)項(xiàng)目。在聲明模塊和路由的庫中,我有以下代碼:parent-routing.module.ts:import {NgModule} from '@angular/core';import {RouterModule, Routes} from '@angular/router';import {ParentComponent} from './parent.component';const routes: Routes = [ { path: '', component: ParentComponent, children: [ { path: '', loadChildren: '/child/child.module#ChildModule' } ] }];@NgModule({ imports: [ RouterModule.forChild(routes) ], exports: [ RouterModule ]})export class ParentRoutingModule {}在app.module.ts 中,我聲明ParentModule如下:const routes: Routes = [ { path: '', loadChildren: () => import('ui-lib').then(m => m.ParentModule) }];@NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule]})export class AppRoutingModule { }當(dāng)我嘗試編譯我的應(yīng)用程序時(shí),控制臺(tái)向我拋出一個(gè)錯(cuò)誤:./src/app/app-routing.module.ts 中的錯(cuò)誤找不到模塊:錯(cuò)誤:無法解析 './../../../../dist/ui-lib/modules/parent/ '/Users/linhnguyen/nested-module-playground/projects/main-app/src/app' 中的 parent.module.d.ngfactory'在谷歌上搜索后,我找到了這條評(píng)論。評(píng)論者提到創(chuàng)建一個(gè)模塊并將每個(gè)組件導(dǎo)入到路由中。這樣可以解決庫中加載模塊的問題,但不是懶加載。請(qǐng)問有人有任何解決方案嗎?
無法在庫中使用嵌套的延遲加載模塊構(gòu)建 angular 8 應(yīng)用程序
湖上湖
2021-10-21 16:40:43