定义“路由词典”,注册Router和Routes。
src\app\app.module.ts
import { RouterModule } from '@angular/router'
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BlueComponent } from './blue/blue.component';
import { YellowComponent } from './yellow/yellow.component';
import { RouterModule } from '@angular/router';
import { WhiteComponent } from './white/white.component'
//声明路由词典——路由地址和路由组件的对应集合
let routes = [
{path:'blue',component:BlueComponent},
{path:'yellow',component:YellowComponent},
{path:'',redireactTo:'/white',pathMatch:'full',component:WhiteComponent},
{path: '**', component: BlueComponent },
]
@NgModule({