http://local.xxxxx.com/node/190/author
app-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app/app.component';
import { HomeComponent } from './home/home.component';
import { BlankComponent } from './blank/blank.component';
const childRoutes = [
{
path: 'author/preview',
data: {
routeLabel: 'preview'
},
loadChildren: () => import('./frame/frame.module').then(m => m.FrameModule)
},
{
path: 'author',
canActivate: [DraftContentGuard, ContentEditorAccessGuard],
data: {
routeLabel: 'edit'
},
loadChildren: () => import('./frame/frame.module').then(m => m.FrameModule)
},
];
const routes: Routes = [
{
path: ':locale/:type/:contentId',
component: AppComponent,
canActivate: [EnabledWebSegmentAccessGuard],
children: childRoutes
},
{path: 'author', component: HomeComponent},
{path: '', redirectTo: '/author', pathMatch: 'full'},
{path: '**', component: BlankComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {paramsInheritanceStrategy: 'always'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
frame.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FrameRoutingModule } from './frame-routing.module';
import { FrameComponent } from './frame.component';
@NgModule({
imports: [
CommonModule,
FrameRoutingModule
],
declarations: [FrameComponent]
})
export class FrameModule { }
frame-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { FrameComponent } from './frame.component';
const routes: Routes = [
{
path: '',
component: FrameComponent,
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FrameRoutingModule { }
大多数文档,文章和教程使用的是不同的localhost服务器,因此我不确定服务器配置是否应该更改以适合延迟加载。
答案 0 :(得分:2)
我也遇到同样的问题。然后我更改了以下内容
我不知道这是否正确,但是对我有用
{ path: '<$Path>',loadChildren:() => import('./<$module folder name>/<$YOUR Module name>.module').then(m => m.<$Modulename>)}
我改为了
import {<$Modulename>} from '/<$Modulepath>';
{ path: '<$Path>', loadChildren:() => {return <$Modulename>;} }