Dear Teacher, 请问<router-outlet></router-outlet>为何无法识别?

来源:2-5 Input 组件

Unravel_lee

2017-10-16

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. ("

    </mat-icon>

  </button> -->

  [ERROR ->]<router-outlet></router-outlet>



"): ng:///AppModule/AppComponent.html@12:2


写回答

1回答

接灰的电子产品

2017-10-16

要学会自己看懂报错信息, router-outlet 是一个组件,而这个组件肯定要属于某个模块,你需要导入该模块来使用这个组件。那么这个模块是什么呢?就是 RouterModule 了。那么你在module 的 imports 数组中导入RouterModule 就好了


0
0

Angular打造企业级协作平台,让你在Angular领域中出类拔萃

全网首个介绍官方 Material 组件库用法与 Redux 在 Angular 中的应用

998 学习 · 536 问题

查看课程