echarts安装创建图表时报这种错误:Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘init’)”
1 .具体报错内容:
2.解决办法:
原先大家可能是这样的写法
import echarts from 'echarts'
后面改为这样导入就不会出错了
import * as echarts from 'echarts'
3.原因:
个人感觉跟我们导入的方法有关,如果采用这种 import echarts1 from ‘echarts’ 导入,它是import导入的简便形式,其含义是把echarts里面的默认暴露都存在变量echarts1 里面,而报错是因为我们引用echarts里面的init方法