首页 > 解决方案 > 错误:BrowserModule 已加载。, 改为导入 CommonModule

问题描述

我已经使用 IntegralUIModule 来实现 TreeGrid,但在模块实现方面存在问题。由于 CommonModule 也存在于来自 Node_Modules 的 IntegralUIModule

ERROR Error: Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.
Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

我的自定义模块.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
// import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { PanelsModule } from 'src/app/shared/panels/panels.module';
import { GLGDemoComponent } from './glg-demo1/glg-demo.component';
import { GLGDemo2Component } from './glg-demo2/glg-demo2.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { IntegralUIModule } from '../../../../node_modules/@lidorsystems/integralui-web/bin/integralui/integralui.module';

@NgModule({
  declarations: [GLGDemoComponent, GLGDemo2Component],
  providers: [],
  imports: [
    CommonModule,
    FormsModule,
    PanelsModule,
    ReactiveFormsModule,
    IntegralUIModule,
    RouterModule.forChild([
      { path: '', pathMatch: 'full', component: GLGDemoComponent, data: { breadcrumbs: ['GLG', 'Screen 1'] } },
      { path: 'screen1', component: GLGDemoComponent, data: { breadcrumbs: ['GLG', 'Screen 1'] } },
      { path: 'TreeGrid', component: GLGDemo2Component, data: { breadcrumbs: ['Tree Grid', 'Grid'] } },
     ])
  ]
})
export class GLGDemoModule { }

标签: angulartypescript

解决方案


推荐阅读