首先,来看一下报错实例:
在用vue ui 创建项目,引入Echarts图表的时候,终端报了'Error in mounted hook: "TypeError: Cannot read properties of undefined (reading 'init') " '的错误,翻译为:“挂载的钩子中出现错误:“TypeError:无法读取未定义的属性(读取'init')”。
解决办法:用import * as echarts from 'echarts' 替换 import echarts from 'echarts',便可以有效解决。
示例代码: