Angular7:延迟加载不创建块

问题描述 投票:0回答:1

我正在使用Angular7,我正在使用新语法,即loadChildren用于延迟加载模块。但是,当我提供我的应用程序并在浏览器中检查时,我发现它不会创建任何块。

enter image description here

以下是我的App-routing

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

const routes: Routes = [
  { path: '', loadChildren: './layout/layout.module#LayoutModule' },
  { path: 'auth', loadChildren: './auth/auth.module#AuthModule' },
  { path: 'not-found', loadChildren: './not-found/not-found.module#NotFoundModule' },
  { path: '**', redirectTo: 'not-found' }
];

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

下面是我的App模块i

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

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

// imports for internationalization i18n
import { HttpClientModule } from '@angular/common/http';
import { LanguageTranslationModule } from './language-translation/language-translation.module';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    LanguageTranslationModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
}
javascript angular lazy-loading angular7 angular-load-children
1个回答
0
投票

如图所示,确实创建了块。

并没有找到模块没有出现这是正常的。

© www.soinside.com 2019 - 2024. All rights reserved.