1. 第一次获取数据时候的初始化数据 封装成组件
<template>
<div :class="{ echartPiebox: true, [this.ids]: true }"></div>
</template>
<script>
export default {
name: "echartPie1",
data() {
return {
option: {},
};
},
props: ["ids", "optiontype1data"],
created() {
this.$nextTick(() => {
setTimeout(() => {
this.initEchart();
}, 300);
});
},
methods: {
initEchart() {
let _this = this;
this.option = this.optiontype1data;
let chartDom = document.querySelector("." + this.ids);
let myChart = this.$echarts.init(chartDom, "light");
myChart.setOption(this.option);
myChart.off("click");
myChart.on("click", function (params) {
_th