“TypeError: Cannot read property ‘init‘ of undefined”在Vue中使用echarts,导入时报错

本文介绍了在使用ECharts时遇到的一个常见问题及其解决方案。当在项目中引入ECharts库时,正确的导入方式应该是使用import * as echarts from 'echarts'而非import echarts from 'echarts'。这一改动能够确保所有ECharts的功能正常工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
解决:在引用时:
import echarts from ‘echarts’ 改为 import * as echarts from ‘echarts’