引入echarts时报错 “TypeError: Cannot read properties of undefined (reading ‘init‘)“的解决方案

  1. 报错实例
    在vue当中引入Echarts图表的时候,终端报了"TypeError: Cannot read properties of undefined (reading ‘init’) " ‘的错误,翻译为:“TypeError:无法读取未定义的属性(读取’init’)”。
    引入echarts时报错 “TypeError: Cannot read properties of undefined (reading ‘init‘)“的解决方案_第1张图片
  2. 解决方法
    用import * as echarts from ‘echarts’ 替换 import echarts from ‘echarts’,便可以有效解决。
import * as echarts from 'echarts' 

引入echarts时报错 “TypeError: Cannot read properties of undefined (reading ‘init‘)“的解决方案_第2张图片

你可能感兴趣的:(Echarts,echarts,vue.js,javascript)