在Vue项目中,引入Echarts库后,运行项目,出现以下报错:
"export 'default' (imported as 'echarts') was not found in 'echarts'
引入Echarts的语句为
import echarts from 'echarts';
原因:
Echarts 5.x 不再支持上面的引入方式,这一点Echarts官网(升级指南)有说明,如下图:

1、按上述图片将
import echarts from 'echarts';
改为
import * as echarts from 'echarts';
2、重装Echarts,卸载掉Echars5.x,装Echarts4.x,同样可以解决问题。
我是改成Echart5.x的引入方式,最后成功显示出图表。
方式一:全局注入Echarts

方式二:单页面引入

画图



网友评论