我已经从旧导入方式中更改了路由器导入的导入,
loadChildren: './lazy/lazy.module#LazyModule
我使用了动态导入来加载路由器模块。
loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)
现在,我不是在渲染组件,而是渲染组件,同时标头和页脚,组件加载正常,因为它没有从路由器输出中加载。
app.component.html
<header-component>. //rendering fine
<router-outlet></router-outlet>. // I am seeing it gets routed in the address bar, but the component is not getting rendering.
<footer-component> //rendering fine
我在上述问题的控制台或VSCODE上没有任何错误。
当组件空白时,我该如何调试此问题,尽管它的路由正确,但我也将在“网络”选项卡中获得此组件的API响应,因此API响应不会在屏幕上以HTML呈现。
当我从Angular 11升级到12版时,这个问题发生在我身上。
我的详细代码结构与此文档
I have changed my router import from old way of importing
loadChildren: './lazy/lazy.module#LazyModule
I have used dynamic import to load the router module.
loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)
Now, my is not rendering the components but at the same time header and footer, component are loading fine since it is not loaded from the router-outlet.
app.component.html
<header-component>. //rendering fine
<router-outlet></router-outlet>. // I am seeing it gets routed in the address bar, but the component is not getting rendering.
<footer-component> //rendering fine
I don't get any error on the console or vscode for the above issue.
How do I debug this issue while the components are blank though it is routed correctly also I am getting an API response for this component in the network tab the API response is not get rendered on the screen as HTML.
This issue happened to me while I am upgrading from Angular 11 to the 12 version.
My detailed code structure is pretty same like this document https://remotestack.io/angular-lazy-load-modules-with-dynamic-module-imports-example/
发布评论
评论(1)
@jsbeginner请共享您的lazymodule代码,似乎您需要在lazymodule模块中指定如何配置路由
,然后
在lazymodule的导入中添加此代码行
@JSBeginner please share your LazyModule code, and it seems you need to specify how you configured routes in the LazyModule module
for example
and add this line of code on imports of lazyModule