我正在尝试使用Webpack构建Angular 6 SPA进行生产。
我的SPA基于模板化项目here。
但是,当我运行webpack --env=prod
(运行webpack --env=dev
时没有错误,尽管我警告被禁止)时,我得到了以下错误(在我的自定义组件上);
: 'burlington' is not a known element:
1. If 'burlington' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<div class='row margin-bottom'>
<div class='col-md-12'>
[ERROR ->]<burlington></burlington>
</div>
</div>
")
现在,我已将新组件添加到shared/components/burlington
文件夹位置。 (参考目录shared/components/burlington/burlington.ts
);
import { Component, Input } from "@angular/core";
import { Image, GalleryService } from "@ks89/angular-modal-gallery";
import { ImageService } from "./../../../core/services/image.service";
import { Subscription } from "rxjs";
import { Observable } from "rxjs/Observable";
@Component({
selector: "burlington",
templateUrl: "./theBurlington.component.html",
styleUrls: ["./theBurlington.component.scss"],
providers: [ImageService]
})
export class BurlingtonComponent {
//removed for brevity...
});
然后我将其添加到declarations
的{{1}}和exports
部分。
shared.module.js
然后我将NgModule({
imports: [
CommonModule,
RouterModule,
FormsModule,
SwiperModule,
ModalGalleryModule.forRoot(),
ReactiveFormsModule
],
declarations: [
NavMenuComponent,
NavSocialComponent,
BurlingtonComponent
],
exports: [
NavMenuComponent,
NavSocialComponent,
BurlingtonComponent
]
})
导入SharedModule
目录下的home.module.ts
中。
/home
然后在我的import { CommonModule } from "@angular/common";
import { HttpClientModule } from "@angular/common/http";
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { SharedModule } from "../shared/shared.module";
import { HomeComponent } from "./components/home.component";
import { HomeRoutes } from "./home.routes";
@NgModule({
imports: [
CommonModule,
FormsModule,
HttpClientModule,
SharedModule,
HomeRoutes
],
declarations: [
HomeComponent
],
exports: [
HomeComponent
]
})
export class HomeModule { }
中,只需添加标签,即home.component.html
。
谁能解释为什么会发生此错误?我在这里想念东西吗?