0
点赞
收藏
分享

微信扫一扫

在Vue脚手架中使用echarts,并解决“TypeError: Cannot read property ‘init‘ of undefined”报错

承蒙不弃 2021-09-23 阅读 130

在Vue中使用echarts,并解决“TypeError: Cannot read property ‘init’ of undefined”报错

1.安装echarts依赖

npm install echarts --save-dev

2.main.js 引入

import echarts from 'echarts'

Vue.prototype.$echarts = echarts

以为这就完了?

控制台很不客气的报错“TypeError: Cannot read property ‘init’ of undefined”

解决办法:main.js中的import echarts from 'echarts’改为import * as echarts from ‘echarts’

3.新建一个Echarts.vue,方法在mounted生命周期中调用

举报

相关推荐

0 条评论