先安装
cnpm install echarts -S
在引入
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts
使用
<div id="myChart" :style="{width: '600px', height: '600px'}"></div>
js部分代码:
export default {
mounted(){
this.drawLine();
},
methods: {
drawLine(){
let myChart = this.$echarts.init(document.getElementById('myChart'))
myChart.setOption({
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
}]
});
}
}
}