TypeError: Cannot read properties of undefined (reading 'init') occurs when using echart5.2 in vue

Using echart in the VUE project, the version 4.8 used before, everything works fine.
But after changing the version of echart to 5.2, the following error appears:

TypeError: Cannot read properties of undefined (reading 'init')"

Check the official document:
Apache ECharts 5 Upgrade Guide
has a clear description, the change of the reference method:
1. If the user references echarts in v4 like this:

import echarts from 'echarts';
// 或者按需引入
import echarts from 'echarts/lib/echarts';
这两种方式,v5 中不再支持了。

2. Users need to change the code as follows to solve this problem:

import * as echarts from 'echarts';
// 按需引入
import * as echarts from 'echarts/lib/echarts';
按需引入

Of course, lowering the version of echarts can also solve this problem.

Guess you like

Origin blog.csdn.net/qgbihc/article/details/120452250