未被捕获(承诺):ChunkLoadError:正在加载块...“仅适用于firefox(Angular 9.1.2)

时间:2020-04-16 11:48:36

标签: javascript angular typescript firefox

我不明白为什么我的应用程序不能在Firefox上运行而在Chrome上运行。

error in firefox

使用loadChildren删除import()的工作原理...


import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {LayoutComponent} from './layout/layout.component';

const appRoutes: Routes = [
  {
    path: '', component: LayoutComponent,
    children: [
      {path: '', redirectTo: 'components', pathMatch: 'full'},
      {
        path: 'components',
        loadChildren: () => import('./pages/component-creator/component-creator.module').then(m => m.ComponentCreatorModule)
      },
      {
        path: 'templates',
        loadChildren: () => import('./pages/template-creator/template-creator.module').then(m => m.TemplateCreatorModule)
      },
    ]
  },

  // Not found
  {path: '**', redirectTo: 'components'},

];

@NgModule({
  imports: [RouterModule.forRoot(appRoutes, {
    enableTracing: false, // tracing for debug
    onSameUrlNavigation: 'reload',
  })],
  exports: [RouterModule]
})
export class AppRoutingModule {
}

注意:<base href="/">

有什么想法吗?

谢谢!

0 个答案:

没有答案