在vue中使用vue-echart
首先在package.json中引入vue-charts 和echar的依赖

我使用的是idea,右击package.json选择 run yarn install 或者是 run npm install 更新node_modules

在main.js中全局引入
import ECharts from 'vue-echarts/components/ECharts'
Vue.component('e-chart', ECharts);
根据使用的不同去引入不同的包,具体在node_modules中 echart/lib/component文件夹下
import 'echarts/lib/chart/line'; (折线)
import 'echarts/lib/chart/bar'; (柱状图)
import 'echarts/lib/chart/pie'; (饼图)
import "echarts/lib/component/tooltip"; (提示框)
import "echarts/lib/component/legend"; (图例组件)
就跟官网一样使用,官网网址:https://echarts.apache.org/zh/api.html#echarts
//在全局中将组件注册为e -chart直接使用 <e-chart :options="option"/> data(){ { option: { xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }] }, } }

浙公网安备 33010602011771号