ngular6开发不完全笔记(三)-- 报错指南


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指令, 根据自己的写法调整, 二者选一即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM