角度6中的量规表组件生成错误

时间:2019-01-08 05:12:27

标签: d3.js angular6

我正在使用https://github.com/recogizer/angular-gauge-chart中的角度规组件 在当地环境下效果很好。但是,当我们使用ng build --prod进行生产构建时,会抛出此错误。我创建了一个单独的模块,并将仪表组件移至该模块,仍然出现错误

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GaugeChartComponent } from 'angular-gauge-chart';

@NgModule({
  imports: [
   CommonModule
 ],
  declarations: [GaugeChartComponent],
  exports: [GaugeChartComponent]
})
 export class GuageGraphModule {

 }

并将此模块导入到我的主模块中,

import { AdministratorService } from ./administrator/administrator.service';
import { GuageGraphModule } from './developement/audit/guage-graph/guage- 
  graph.module';


  // AoT requires an exported function for factories
  export function HttpLoaderFactory(httpClient: HttpClient) {
  return new TranslateHttpLoader(httpClient);
  }

    @NgModule({
   declarations: [

     MainComponent,
    AdministratorComponent,
   NewUserComponent,
    ModifyUserComponent,   

  ],
     imports: [   
   UiSwitchModule,
    GuageGraphModule,

    })
   ], exports: [
      MainComponent
      ],
   providers: [ AdministratorService, ],
  })
           export class MainModule { }

我收到的错误是

  

错误:在C:/Users/Documents/projDec/app/node_modules/angular-gauge-chart/angular-gauge-chart.d.ts中键入GaugeChartComponent是以下两个模块的声明的一部分:C中的GuageGraphModule :/ Users / Documents / proj Dec / app / src / app / main / development / audit / guage-graph / guage-graph.module.ts和GaugeChartModule在C:/ Users / Documents / proj Dec / app / node_modules / angular -gauge-chart / angular-gauge-chart.d.ts!请考虑将C:/ Users / Documents / proj Dec / app / node_modules / angular-gauge-chart / angular-gauge-chart.d.ts中的GaugeChartComponent移至更高的模块,该模块在C:/ Users / Documents / proj中导入GuageGraphModule Dec / app / src / app / main / development / audit / guage-graph / guage-graph.module.ts和GaugeChartModule在C:/ Users / Documents / proj Dec / app / node_modules / angular-gauge-chart / angular-仪表图您还可以创建一个新的NgModule,该文件在C:/ Users / Documents / proj Dec / app / node_modules / angular-gauge-chart / angular-gauge-chart.d.ts中导出并包含GaugeChartComponent,然后在C的GuageGraphModule中将该NgModule导入:/ Users / Documents / proj Dec / app / src / app / main / development / audit / guage-graph / guage-graph.module.ts和GaugeChartModule在C:/ Users / Documents / proj Dec / app / node_modules / angular -gauge-chart / angular-gauge-chart.d.ts。

1 个答案:

答案 0 :(得分:1)

无需创建单独的模块并将量规组件移至该模块。 仅将GaugeChartModule导入主模块。

import { AdministratorService } from ./administrator/administrator.service';
import { GaugeChartModule } from 'angular-gauge-chart';


  // AoT requires an exported function for factories
  export function HttpLoaderFactory(httpClient: HttpClient) {
  return new TranslateHttpLoader(httpClient);
  }

    @NgModule({
   declarations: [

     MainComponent,
    AdministratorComponent,
   NewUserComponent,
    ModifyUserComponent,   

  ],
     imports: [   
   UiSwitchModule,
    GaugeChartModule,

    })
   ], exports: [
      MainComponent
      ],
   providers: [ AdministratorService, ],
  })
           export class MainModule { }

请勿在mainModule中使用import { GaugeChartComponent } from 'angular-gauge-chart';