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