In Vue, use echorts to report an error: “typeerror: cannot read property ‘init’ of undefined” error reporting reason and solution

The latest version of ecarts dependency, version 5. X, is installed through NPM. However, most of the online tutorials are introduced in the way of 4. X, while the introduction method of version 5. X has changed, resulting in an error;

Solution

The method of introducing main.js into ecarts is introduced from 4. X:

import echarts from 'echarts' 

Change to 5. X import mode:

import * as echarts from 'echarts'

Read More: