多个组件中的子路由

时间:2018-12-11 12:09:23

标签: angular6

无法显示子组件的html页面

创建了home组件并添加了home-routing.module

import {
  NgModule
} from '@angular/core';
import {
  Routes,
  RouterModule
} from '@angular/router';
import {
  HomeComponent
} from './home.component';

const routes: Routes = [{
  path: 'home',
  component: HomeComponent
}];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class HomeRoutingModule {}

import {
  NgModule
} from '@angular/core';
import {
  Routes,
  RouterModule
} from '@angular/router';

const routes: Routes = [{
  path: 'home',
  children: [{
    path: '',
    loadChildren: 'src/app/home/home.module#HomeModule'
  }]
}];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

,浏览器页面不显示任何内容,URL地址不变 http://localhost:4200/#/home

0 个答案:

没有答案