because every chart is the same, you want to use v-for to loop the echart chart
Code of the loop
<el-col :span="6" v-for="(item,index) of items" :key="item.id">
<div class="body">
<div class="echart" :id="getID(index)"></div>
</div>
</el-col>
dynamic id
getID(index) {
return "echart_" + index;
}
id bound by echart
mounted() {
this.$nextTick(function() {
this.drawPie("chart");
});
},
drawPie(id) {
this.charts = echarts.init(document.getElementById(id));
},
how to write the id of echart as ID in the getID () method