在此stackblitz demo中,auth.routing.ts模块导入RouterModule并使用它为LoginComponent配置路由。然后,它还会再次输出RouterModule,如下所示:

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})


只是好奇是否有必要,因为RouterModule似乎必须在App中全局可用?

最佳答案

不需要导出RouterModuleHere is a stackblitz demo showing that the creation and use of the AuthRoutingModule without an export of the RouterModule

10-06 00:15