import{createApp,h}from'vue';importechartsfrom'echarts';import{plugin}from'echarts-for-vue';constapp=createApp({/*...*/});app.use(plugin,{ echarts, h });// use as a plugin
<template><EChartsref="chart" :option="option" />
</template><script>importechartsfrom'echarts';import{h}from'vue';import{createComponent}from'echarts-for-vue';exportdefault{components: {ECharts: createComponent(echarts,h),// use as a component},data(){return{option: {/*...*/},};},methods: {doSomething(){this.$refs.chart.inst.getWidth();// call the method of the ECharts instance}}}</script>
Vue 2
importVuefrom'vue';importechartsfrom'echarts';import{plugin}from'echarts-for-vue';Vue.use(plugin,{ echarts });// use as a plugin
<template><EChartsref="chart" :option="option" />
</template><script>importechartsfrom'echarts';import{createComponent}from'echarts-for-vue';exportdefault{components: {ECharts: createComponent(echarts),// use as a component},data(){return{option: {/*...*/},};},methods: {doSomething(){this.$refs.chart.inst.getWidth();// call the method of the ECharts instance}}}</script>