[Echarts] TypeError: Cannot read property 'init' of undefined

Author: SimZhouCreated Jul 20, 2020Updated Sep 2, 2024

Hi, so when using echarts, I followed the template from vue-element-admin, however i got TypeError: Cannot read property 'init' of undefined: error

So I checked the internet and found a solution. By adding the following two lines into my chart.vue fixs my problem:

import Vue from 'vue'
Vue.prototype.$echarts = echarts

(reference)

I am wondering why is this needed and why in vue-element-admin it does not need those two lines?

Similar issue on echarts: #187 (But mine is different, I just wanna know why I cannot do the same thing as vue-element-admin and get it right)

Source: PanJiaChen/vue-admin-template