儿童中使用lazyLoading进行路由无法正常工作-无法匹配路由

时间:2019-01-25 12:54:05

标签: angular

这是我的应用设置:

enter image description here

这是我的 app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SoftwareComponent } from './components/software/software.component';

const routes: Routes = [
    {
        path: '',
        outlet: 'main',
        component: SoftwareComponent,
        children: [
            {
                path: 'personal',
                children: [
                    {
                        path: '',
                        loadChildren: './components/software/data/personal/personal.module#PersonalModule' 
                    }
                ]
            }
        ]
    }   
];

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

我的错误是:

  

错误错误:未捕获(承诺):错误:无法匹配任何路由。网址段:“个人”   错误:无法匹配任何路线。网址段:“个人”

也许有人可以告诉我我的设置有什么问题吗?

1 个答案:

答案 0 :(得分:1)

personal移动到与第一个''相同的级别。

const routes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        redirectTo: 'personal'
    },
    {
        path: 'personal',
        outlet: 'main',
        component: SoftwareComponent,
        children: [
            {
                path: '',
                loadChildren: './components/software/data/personal/personal.module#PersonalModule' 
            },
            {
                path: '',
                loadChildren: './components/software/header/header-personal/header-personal.module#HeaderPersonalModule'
            }
        ]
      }
    }   
];