flex: echarts resize 方法

This commit is contained in:
@changcode
2022-07-14 17:15:34 +08:00
parent c367966e04
commit 381a4e1a66
2 changed files with 9 additions and 1 deletions

View File

@@ -5907,7 +5907,6 @@ export default {
return str return str
} }
this.myChart.setOption(this.chartOption) this.myChart.setOption(this.chartOption)
this.myChart.resize()
}, },
dispatchLegendSelectAction (name) { dispatchLegendSelectAction (name) {
@@ -5954,12 +5953,16 @@ export default {
}) })
} }
} }
},
resize () {
this.myChart.resize()
} }
}, },
mounted () { mounted () {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.init() this.init()
}, 100) }, 100)
window.addEventListener('resize', this.resize)
}, },
beforeUnmount () { beforeUnmount () {
clearTimeout(this.timer) clearTimeout(this.timer)

View File

@@ -61,12 +61,17 @@ export default {
this.chartOption2.series[0].data = this.chartData2 this.chartOption2.series[0].data = this.chartData2
this.myChart2.setOption(pieChartOption2) this.myChart2.setOption(pieChartOption2)
} }
},
resize () {
this.myChart.resize()
this.myChart2.resize()
} }
}, },
mounted () { mounted () {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.init() this.init()
}, 100) }, 100)
window.addEventListener('resize', this.resize)
}, },
beforeUnmount () { beforeUnmount () {
clearTimeout(this.timer) clearTimeout(this.timer)