fix:数据初始渲染不出来的问题

This commit is contained in:
guoyue 2022-06-30 10:39:02 +08:00
parent 9e045b0503
commit 42fcb9e7cc
1 changed files with 10 additions and 5 deletions

View File

@ -17,9 +17,6 @@ export default {
myChart: null, myChart: null,
} }
}, },
mounted() {
this.init()
},
props: { props: {
id: { id: {
type: String, type: String,
@ -40,7 +37,10 @@ export default {
if (newVal) { if (newVal) {
this.dataListCopy = newVal; this.dataListCopy = newVal;
if (document.getElementById(this.id)) { if (document.getElementById(this.id)) {
this.init() //
setTimeout(() => {
this.initChart()
}, 1000)
} }
} }
}, },
@ -48,8 +48,13 @@ export default {
immediate: true immediate: true
}, },
}, },
mounted() {
setTimeout(() => {
this.initChart()
}, 1000)
},
methods: { methods: {
init() { initChart() {
var chartDom = document.getElementById(this.id); var chartDom = document.getElementById(this.id);
if (this.myChart) { if (this.myChart) {
this.myChart.dispose() this.myChart.dispose()