1. First create a Vue project, and then enter it in the console
//安装 echarts
npm install echarts --save
2. Next, introduce it in main.js
// 引入Echarts
import echarts from "echarts"
Vue.prototype.$echarts = echarts
3. Create a Vue page for a simple display of the Echarts curve
<template>
<div class="EchartPractice">
<div id="main"></div>
</div>
</template>
<script>
export default {
name: "EchartPractice",
methods:{
drawChart() {
let myEchart = this.$echarts.init(document.getElementById("main"));
let option = {
xAxis: {
data: ['7.8', '7.9', '7.10', '7.11', '7.12', '7.13', '7.14']
},
yAxis: {},
series: [{
data: [60, 80, 100, 120, 200, 170,180],
type: 'line',
smooth: true,
symbol: "none",
areaStyle: {
color: '#344CE9',
opacity: 0.5
}
}]
};
myEchart.setOption(option);
}
},
mounted() {
this.drawChart();
}
}
</script>
<style scoped>
#main {
width: 600px;
height:400px;
margin: auto;
margin-top: 100px
}
</style>
4. The page effect is shown in the figure below