安装echarts模块
cnpm install echarts
vue中main文件夹引入
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
代码案例
<div class="l2">
<div id="main" style="width: 600px;height:400px;" ref="charts"></div>
</div>
export default {
mounted(){
this.drawLine()
},
methods: {
drawLine() {
let myChart = this.$echarts.init(document.getElementById('main'))
myChart.setOption({
title: {
},
tooltip: {},
xAxis: {
data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
});
}
}
}