npm install echarts -S
import echarts from 'echarts'
Vue.use(echarts)
<template>
<div>
<!-- 统计图容器 -->
<div id="main" style="width: 100%;height: 270px;" />
</div>
</template>
<script>
export default {
data() {
return {}
},
mounted() {
var echarts = require('echarts')
// 初始化echarts实例
var myChart = echarts.init(document.getElementById('main'))
// 配置参数
var option = {
title: {
text: '兑换情况'
},
tooltip: {},
legend: {
data: ['销量']
},
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
}
myChart.setOption(option)
}
}
</script>