安装
代码语言:javascript复制npm install echarts -S
main.js全局引入
代码语言:javascript复制import echarts from 'echarts'
Vue.prototype.$echarts = echarts
代码语言:javascript复制<template>
<div class="box">
<div id="polyLineChart" :style="{width: '300px', height: '300px'}"></div>
</div>
</template>
<script>
export default {
data() {
return {};
},
mounted() {
this.polyLineChart();
},
methods: {
polyLineChart() {
var myChart = this.$echarts.init(
document.getElementById("polyLineChart")
);
var option = {
xAxis: {
type: "category",
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
},
yAxis: {
type: "value"
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: "line"
}
]
};
myChart.setOption(option);
}
}
};
</script>
<style lang="less" scoped>
.box {
padding: 30px;
box-sizing: border-box;
}
</style>