<template>
<div>
<div :id="id+'mod'" :data="data" :style="{ width:'100%', height: height}"></div>
</div>
</template>
<script>
import { randomString } from "@/assets/js/common.js";
export default {
props: {
data: Object,
height: String
},
data() {
return {
id: "",
};
},
watch: {
data: {
handler(newName, oldName) {
this.drawModelGraph(newName)
},
immediate: true,
deep:true
}
},
mounted() {
this.drawModelGraph(this.data)
},
methods: {
drawModelGraph(data) {
setTimeout(() => {
let modelChart = document.getElementById(this.id+'mod');
this.ChartModelGraph = this.$echarts.init(modelChart);
this.ChartModelGraph.setOption(data);
}, 500);
},
},
beforeDestroy() {
if (this.ChartModelGraph) {
th
chart组件的封装
于 2020-12-24 16:07:05 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)