Files
ptools/static/js/echarts-component.js
2022-11-26 11:46:49 +08:00

28 lines
687 B
JavaScript
Raw Permalink 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.
/**
* 封装echarts可以在vue中使用
*/
Vue.component('charts', {
props: ['option', 'style'], data: function () {
return {}
}, mounted: function () {
this.$nextTick(function () {
var el = this.$el;
var chart = echarts.init(el, 'dark');
chart.setOption(this.option);
this.chart = chart
})
}, watch: {
obj: {
option(newValue, oldValue) {
// option发生变化时自动重新渲染
this.chart.setOption(newValue)
}, // immediate: true,
deep: true,
}
}, template: '<div :style="style">{{option}}</div>'
})