Using echarts in Vue3 to report an error handling Cannot read properties of undefined (reading 'init')

1. A difference in main.js between vue 2 and vue 3 

        Generally, we need to write import * as echarts from 'echarts' in main.js in addition to the command npm install echarts --save to install. Note: ( import echarts from 'echarts') is easy to report errors,  so in most cases write as follows:

import * as echarts from 'echarts'

But here comes our focus:

 We have tried the following three methods without any effect:

import  echarts from 'echarts'
improt  * as echarts from 'echarts

 Finally, add require directly in mounted to solve the problem

 If there is a better way, suggestions are welcome in time!

Guess you like

Origin blog.csdn.net/qq_45904018/article/details/126487580