代码:
<template>
<div class="echarts-container">
<div id="main"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'echarts-container',
data () {
return {
option: {
xAxis: {
type: 'category',
name: '姓名',
data: ['王一', '赵二', '张三', '李四', '王五', '赵六', '礼小七']
},
yAxis: {
type: 'value',
name: '完成数量'
},
series: [
{
data: [180, 230, 224, 218, 135, 147, 260],
type: 'line'
}
]
}
}
},
mounted () {
// const echartsDom = document.querySelector('#main')
const myChart = echarts.init(document.querySelector('#main'))
myChart.setOption(this.option)
}
}
</script>
<style scoped lang="less">
#main {
margin: 100px auto;
width: 380px;
height: 230px;
background-color: rgb(33, 194, 119);
}
</style>