一、配置一个路由模块

  1. ng g module views/home --routing
  2. ng g component views/home //配置主组件

二、配置模块中的路由

  1. //home-routing.module.ts
  2. import { HomeComponent } from './home.component';
  3. const routes: Routes = [
  4. {
  5. path:"",
  6. component:HomeComponent
  7. }
  8. ]

三、配置主路由

  1. const routes: Routes = [
  2. {
  3. path:"home",
  4. loadChildren:()=>import('./views/home/home.module').then(m=>m.HomeModule)
  5. }
  6. ];