gpt4 book ai didi

webpack - 在 Angular 7 版本中延迟加载不起作用

转载 作者:行者123 更新时间:2023-12-04 22:54:55 26 4
gpt4 key购买 nike

我已将 angular 6 版本更新为 angular 7 版本。现在,当我尝试导航到“http://localhost:4200/pages”时出现错误'。我在我的应用程序中使用延迟加载路由概念。

错误:-

core.js:12584 ERROR Error: Uncaught (in promise): Error: Cannot find module './Pages/Test/Test.module' Error: Cannot find module './Pages/Test/Test.module' at $_lazy_route_resource lazy namespace object:5 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:14143) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:14134) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at $_lazy_route_resource lazy namespace object:5 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:14143) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)



app-routing.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes} from '@angular/router';

export const AppRoutes : Routes = [
{
path : '',
redirectTo: 'test',
pathMatch: 'full',
}
{
path: 'test',
loadChildren: './Pages/test/test.module#TestModule'
}
]

告诉我,如何解决这个错误。

最佳答案

在尝试了很多更改后,我发现我的 app.routing.ts 应该是这样的:-

import { TestModule } from './Pages/test/test.module';

export const AppRoutes : Routes = [
{
path : '',
redirectTo: 'test',
pathMatch: 'full',
}
{
path: 'test',
loadChildren: () => TestModule
}
]

更改后这对我来说很完美。

关于webpack - 在 Angular 7 版本中延迟加载不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53120143/

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