Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘init‘)“

前端vue项目使用echarts报错解决方案,亲测有效。

  • 踩坑,在vue中使用echart绘制图表的时候报错Error in mounted hook: "TypeError: Cannot read properties of undefined (reading init )"解决办法
  • 存在问题:导入包的方式不对,使用官方新的导入方式
  • 解决方案
  1. 将main.js下导入的写法变更一下就能解决报错。
// 原导入方式
import echarts from 'echarts'

// 原导入方式 => 现导入方式
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts;
posted @ 2022-06-07 11:33  HuangBingQuan  阅读(5311)  评论(0编辑  收藏  举报