Files
fibo-rule/h5-auth-manager/src/components/common/charts.vue

56 lines
933 B
Vue
Raw Normal View History

2022-07-14 12:55:31 +08:00
<template>
<div :id="sid" :style="{height: height,width:width}">
</div>
</template>
<script>
import * as echarts from 'echarts';
export default {
props: {
sid: {
type: String,
default: 'echartsId'
},
height: {
type: String,
default: '300px'
},
width: {
type: String,
default: '300px'
},
option: {
type: Object,
default () {
return {}
}
}
},
data() {
return {
chartDom: null,
myChart: null
}
},
mounted() {
this.chartDom = document.getElementById(this.sid);
this.myChart = echarts.init(this.chartDom);
this.myChart.setOption(this.option);
},
watch: {
option: {
handler: function() {
this.myChart.clear()
this.myChart.setOption(this.option);
},
// 开启深度监听只要obj中的任何一个属性发生改变都会触发相应的代码
deep: true
}
}
}
</script>
<style>
</style>