router

Uncaught Error: Template parse errors:
'router-outlet' is not a known element:

  1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
  2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  • 解决方法
  1. 每个模块中都添加 import { RouterModule } from '@angular/router'; 然后 import即可
  2. 【推荐】建立shared模块 在分享模块中导入 RouterModule 然后导出,其他有使用 <router-outlet></router-outlet> 的模块都导入 shared模块

主要是导入RouterModule指令, 根据自己的写法调整, 二者选一即可

相关文章:

  • 2021-12-01
  • 2021-11-01
  • 2022-12-23
  • 2021-12-10
  • 2021-12-18
  • 2021-05-01
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2021-07-22
  • 2022-02-01
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案