typeError:无法解构“ object null”的属性“ init”,因为它在ngx电子图表中为null

时间:2020-07-30 15:06:12

标签: angular typescript echarts

当我使用ngx-echarts时得到了这个。使用4.x.x版本时,一切正常。 npm后,我的应用程序无法运行。

2 个答案:

答案 0 :(得分:4)

问题是由于ngxe-charts中的版本更新。如果使用版本> 5.0,请在app.module中使用此版本

    NgxEchartsModule.forRoot({
       echarts: { init: echarts.init }
  })

在tsconfig.json中的角度编译器选项中也添加了此

"enableIvy": false

答案 1 :(得分:0)

@Arokia Lijas 提出的解决方案对我不起作用 它在 build --prod 中产生了错误

所以我找到了这个:

export function chartModule(): any {
      return import('echarts');
        }

在 NgModule 中:

    NgxEchartsModule.forRoot({
  echarts: chartModule
}),

它对我来说效果很好。 来源:https://github.com/xieziyu/ngx-echarts/issues/241#issuecomment-742777787