vue中引入echarts 报错“export ‘default‘ (imported as ‘echarts‘) was not found in ‘echarts‘

问题
引入 echars 5.0 遇到报错 "export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’

解决
引入方式改为

import * as echarts from 'echarts';
// 或
const echarts = require('echarts');

参考的是这篇博主的文章

https://blog.csdn.net/weixin_44874618/article/details/110647652

去看了下我自己的echarts的版本号

npm ls echarts  //查看echarts的版本

一看确实是5.0的
或者在page.json文件查看(这是重装好的,仅做演示)

复制代码
"dependencies": {
"axios": "^0.19.2",
"echarts": "^4.9.0",
"element-ui": "^2.13.2",
"html2canvas": "^1.0.0-rc.7",
"qrcodejs2": "^0.0.2",
"vue": "^2.5.2",
"vue-axios": "^2.1.5",
"vue-qr": "^2.2.1",
"vue-router": "^3.0.1"
},
复制代码


按照这篇博主说的,卸载了重装 echarts

npm uninstall echarts //卸载


重装

npm install echarts@4.9.0
npm fund
npm run dev

这样就好了

 

 效果如下

原文地址:https://www.cnblogs.com/csjoz/p/15511271.html