【问题标题】:typeError: Cannot destructure property 'init' of 'object null' as it is null in ngx e-chartstypeError:无法解构“object null”的属性“init”,因为它在 ngx 电子图表中为 null
【发布时间】:2020-07-30 15:06:12
【问题描述】:

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

【问题讨论】:

    标签: angular typescript echarts


    【解决方案1】:

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

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

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

    "enableIvy": false
    

    【讨论】:

      【解决方案2】:

      @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

      【讨论】:

      • 兄弟,我正在拔头发,非常感谢!
      猜你喜欢
      • 1970-01-01
      • 2022-01-26
      • 2023-01-12
      • 2021-05-26
      • 2021-03-08
      • 2021-05-11
      • 1970-01-01
      • 2022-06-17
      • 2022-07-27
      相关资源
      最近更新 更多