问题描述
我的app-component.html文件如下:
<router-outlet></router-outlet>
<router-outlet name="menu"></router-outlet>
我的app-routing.ts是这样的:
{ path: '',loadChildren: () => import('./features/home/home.module').then(m => m.HomeModule) },{ path: '',outlet: 'menu',loadChildren: () => import('./features/catalog/catalog.module').then(m => m.CatalogModule)}
但是当我启动我的应用程序时,出现以下错误:
core.js:4352 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'routes' of undefined
TypeError: Cannot read property 'routes' of undefined
at getChildConfig (router.js:3046)
这似乎是一个已知的错误,它无法正常工作,所以我尝试了此操作:
{
path: '',component: MenuProxyRouteComponent,children: [{
path: 'test',loadChildren: () => import('./features/catalog/catalog.module').then(m => m.CatalogModule)
},{ path: '**',redirectTo: 'test',pathMatch: 'full' }
]
},
使用我的MenuProxyRouteComponent:
import { Component } from '@angular/core';
@Component({
selector: 'menu-proxy-route',template: '<router-outlet></router-outlet>',})
export class MenuProxyRouteComponent {
}
ERROR in src/renderer/app/features/menu/menu.proxy.component.ts:5:16 - error NG8001: 'router-outlet' is not a kNown element:
1. If 'router-outlet' is an Angular component,then verify that it is part of this module.
2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
5 template: '<router-outlet></router-outlet>',
我不明白为什么会出现此错误,因为我在app.component.html文件中有一个文件,并且工作正常。
有人知道如何在app.component.html中使用延迟加载吗?还是为什么我有第二个错误?
谢谢
解决方法
我将通过一个示例对其进行解释。对于这个多个 private
FRectTool: TTeeCustomTool;
router-outlet
尝试如下更改<router-outlet name="left"></router-outlet>
<router-outlet name="right"></router-outlet>
或相关的路由文件
app-routing.module