gpt4 book ai didi

angular - 延迟加载时找不到模块错误

转载 作者:行者123 更新时间:2023-12-05 08:52:50 25 4
gpt4 key购买 nike

我想为我的模块设置延迟加载,但是有一个我无法解决的错误。

错误是:

core.js:15724 ERROR Error: Uncaught (in promise): Error: Cannot find module 'app/invoice-builder/invoice-builder.module' Error: Cannot find module 'app/invoice-builder/invoice-builder.module'

app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: 'invoice-builder',
loadChildren : 'app/invoice-builder/invoice-builder.module#InvoiceBuilderModule'
},
{
path: '**',
redirectTo: 'invoice-builder'
}
];

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

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import { from } from 'rxjs';
import { MaterialModule } from './shared/material.module';


@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MaterialModule

],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

我不明白这里发生了什么。我尝试了两次使用重新启动项目npm start 但是,那没有用。任何帮助将不胜感激。

最佳答案

我在使用 Angular 9 时遇到了类似的问题,并设法通过使用 found in docs: 的语法修复了它。

const routes: Routes = [
{
path: 'customers',
loadChildren: () => import('./customers/customers.module').then(m => m.CustomersModule)
},
{
path: 'orders',
loadChildren: () => import('./orders/orders.module').then(m => m.OrdersModule)
}
];

关于angular - 延迟加载时找不到模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55605512/

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