gpt4 book ai didi

angular - 未捕获( promise ): ChunkLoadError: Loading chunk xxx-xxx-module failed. Angular 9

转载 作者:行者123 更新时间:2023-12-04 04:09:27 25 4
gpt4 key购买 nike

Angular 9:延迟加载/路由器无法正常工作

控制台错误消息
ERROR Error: Uncaught (in promise): ChunkLoadError: Loading chunk frame-frame-module failed.

路径网址:/author

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 { }


项目结构
Project folders

我怎么看?
大多数文档、文章、教程都使用不同的本地主机服务器,所以我不确定我的服务器配置是否应该更改以在延迟加载下正常工作。
The file is not in my server

最佳答案

我也有同样的问题。然后我更改了以下内容
我不知道这是否是一个正确的程序,但它对我有用

{ path: '<$Path>',loadChildren:() => import('./<$module folder name>/<$YOUR Module name>.module').then(m => m.<$Modulename>)}  
相反,我改为
import {<$Modulename>} from '/<$Modulepath>';
{ path: '<$Path>', loadChildren:() => {return <$Modulename>;} }

关于angular - 未捕获( promise ): ChunkLoadError: Loading chunk xxx-xxx-module failed. Angular 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62009958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com