Angular routing 子组件的角度延迟加载

Angular routing 子组件的角度延迟加载,angular-routing,angular10,Angular Routing,Angular10,我正在angular 10应用程序中实现lazyloading,下面是lazyloading结构 app=>车辆=>两轮车、四轮车 此处车辆从app-routing.module.ts加载,如下所示 import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { path: 'vehicles', loadCh

我正在angular 10应用程序中实现lazyloading,下面是lazyloading结构

app=>车辆=>两轮车、四轮车

此处车辆从app-routing.module.ts加载,如下所示

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

const routes: Routes = [
{ path: 'vehicles', loadChildren: () => import(`./vehicles/vehicles.module`).then(m => m.VehicleModule) },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
下面是车辆路径模块文件

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

import { TwoWheelerComponent } from './twowheeler/twowheeler.component';
import { FourWheelerComponent } from './fourwheeler/fourwheeler.component';

const routes: Routes = [

    { path: '', component: TwoWheelerComponent},
    { path: 'fourWheeler', component: FourWheelerComponent }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class VehicleRoutingModule { }
但我无法理解以下儿童路线之间的区别。 我们什么时候应该使用下面的第一个代码示例,什么时候应该使用第二个

const routes: Routes = [
    { path: '', component: VehiclePageComponent, canActivate: [AuthGuard],
        children: [
            { path: '', component: TwoWheelerComponent},
            { path: 'fourWheeler', component: FourWheelerComponent }
        ]
    }
    ]
                                      and
    const routes: Routes = [
     { path: '', component: TwoWheelerComponent},
     { path: 'fourWheeler', component: FourWheelerComponent }
    ]