eChart 异常(NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG)

0 angular

我在 Angular 7 应用程序中使用 ngx-echart。我正在按照链接中的示例进行操作: https://www.freakyjolly.com/angular-e-charts-using-ngx-echarts-tutorial/#.XwSANigzaUk

但是当执行(ng服务)应用程序并显示组件时,我收到以下错误:

错误错误:StaticInjectorError(AppModule)[NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG]:StaticInjectorError(平台:核心)[NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG]:NullInjectorError:没有 InjectionToken NGX_ECHARTS_CONFIG 的提供程序!在 NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8896) 在resolveToken (core.js:9141) 在 tryResolveToken (core.js:9085) 在 StaticInjector .push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8982) 在resolveToken (core.js:9141) 在tryResolveToken (core.js:9085) 在StaticInjector.push ../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8982) 在resolveNgModuleDep (core.js:21218) 在NgModuleRef_.push../node_modules/@angular/core/fesm5 /core.js.NgModuleRef_.get (core.js:21907) 在resolveNgModuleDep (core.js:21218)

任何想法 ?

谢谢

小智 6

您需要NgxEchartsModule.forRoot({ echarts })在您的模块中添加

import { NgxEchartsModule } from 'ngx-echarts';
import * as echarts from 'echarts';
Run Code Online (Sandbox Code Playgroud)