Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
918 views
in Technique[技术] by (71.8m points)

angular模块作为子路由只能通过懒加载吗

如果模块B中的所有页面都要渲染到模块A的子路由下,那是不是只能通过loadChildren来加载模块B


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

不是呀,你可以直接用 children ,如果不要代码分割和懒加载的话。

模块 B 不要懒加载的话也就不需要 Router.forChild ,让你的主 Routers 把子路由 import 进来放到 children 下就行。

写了一个例子,两个子模块,一个是直接导入到 AppModule,另一个用 routes 里的 loadChildren,这样就和 AppModule 不挂钩了。

https://stackblitz.com/edit/a...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...