1. npm install echarts --save
2. 在main.js文件中
import echarts from ‘echarts‘
Vue.prototype.$echarts = echarts
3. 在展示的组建中
<template>
<div id="main" style="width: 500px; height: 500px"></div>
</template>
<script>
export default {
mounted() {
//挂载实例
this.dwa();
},
//定义一个方法
methods: {
dwa(){
let echarts = require(‘echarts‘);
let myChart = echarts.init(document.getElementById(‘main‘));
myChart.setOption({ title: { text: ‘ECharts 入门示例‘ },
tooltip: {},
xAxis: {
show:false,
data: [‘衬衫‘, ‘羊毛衫‘, ‘雪纺衫‘, ‘裤子‘, ‘高跟鞋‘, ‘袜子‘]
},
yAxis: {
show:false
},
series: [
{
name: ‘a a ‘,
type: ‘pie‘,
data: [20,1,3,4,5,6,7,8,9,10,11,12,13,14,15]
}
]
});
}
},
}
</script>