Files
fibo-rule/h5-auth-manager/src/components/common/charts.vue
2022-07-14 12:55:31 +08:00

56 lines
933 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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>