安装echarts
npm i echarts -s
全局引入
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
在组件中使用
<div id="myChart"></div>
let myChart = this.$echarts.init(document.getElementById('myChart'));
myChart.setOption({
title: {text: '数据'},
xAxis: {
type: 'category',
data: ['0时', '6时', '12时', '18时', '24时']
},
yAxis: {
type: 'value'
},
series: [{
data: [22000, 93222, 90421, 93424, 13290],
type: 'line'
}]
});
id绑定,并初始化