因为每个图表都相同,想要用v-for循环echart图表
循环的代码
<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>
动态的id
getID(index) {
return "echart_" + index;
}
echart绑定的id
mounted() {
this.$nextTick(function() {
this.drawPie("chart");
});
},
drawPie(id) {
this.charts = echarts.init(document.getElementById(id));
},
怎么样将echart的id写成getID()方法中的ID
推荐第二种,vue框架不应该去涉及到dom的任何操作