这是我的代码:
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { LanguageTranslationModule } from './shared/modules/language-translation/language-translation.module'
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AuthGuard } from './shared';
import { SidebarComponent } from './layout/components/sidebar/sidebar.component';
import { HeaderComponent } from './layout/components/header/header.component';
@NgModule({
imports: [
CommonModule,
BrowserAnimationsModule,
HttpClientModule,
LanguageTranslationModule,
AppRoutingModule
],
declarations: [AppComponent,HeaderComponent,SidebarComponent],
providers: [AuthGuard],
bootstrap: [AppComponent],
exports: [
HeaderComponent,
SidebarComponent
],
})
export class AppModule {}
我不知道为什么会出现这个异常:
Error: BrowserModule已被加载。如果您需要从延迟加载的模块中访问常见指令,例如NgIf和NgFor,请改为导入CommonModule。Error: BrowserModule已被加载。如果您需要从延迟加载的模块中访问常见指令,例如NgIf和NgFor,请改为导入
在未来的模块中,我将导入CommonModule
而不是BrowerModule
。有人可以帮我吗?
AppModule
中已经导入了CommonModule
,但需要替换为BrowserModule
。 - Poul Kruijt