angular项目报错 ‘router-outlet’ is not a konwn element

解决方案

  1. 在app.component.spec.ts中
import { RouterTestingModule } from '@angular/router/testing'; describe('AppComponent', () => {beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule//引入 ], declarations: [ AppComponent ], }).compileComponents(); }));

  1. 在app.module.ts中
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, ReactiveFormsModule, RouterModule ], providers: [], bootstrap: [AppComponent] })

【angular项目报错 ‘router-outlet’ is not a konwn element】就可以了,可以试试,我的是这样解决的

    推荐阅读