不是呀,你可以直接用 children ,如果不要代码分割和懒加载的话。模块 B 不要懒加载的话也就不需要 Router.forChild ,让你的主 Routers 把子路由 import 进来放到 children 下就行。写了一个例子,两个子模块,一个是直接导入到 AppModule,另一个用 routes 里的 loadChildren,这样就和 AppModule 不挂钩了。https://stackblitz.com/edit/a...
不是呀,你可以直接用 children ,如果不要代码分割和懒加载的话。
模块 B 不要懒加载的话也就不需要 Router.forChild ,让你的主 Routers 把子路由 import 进来放到 children 下就行。
写了一个例子,两个子模块,一个是直接导入到 AppModule,另一个用 routes 里的 loadChildren,这样就和 AppModule 不挂钩了。
https://stackblitz.com/edit/a...