Skip to content

Commit 4ad9040

Browse files
committed
echarts add watch sidebar resize
1 parent 8460069 commit 4ad9040

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/views/dashboard/editor/lineChart.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
}, 100)
4040
window.addEventListener('resize', this.__resizeHanlder)
4141
}
42+
43+
// 监听侧边栏的变化
44+
const sidebarElm = document.getElementsByClassName('sidebar-container')[0]
45+
sidebarElm.addEventListener('transitionend', this.__resizeHanlder)
4246
},
4347
beforeDestroy() {
4448
if (!this.chart) {
@@ -47,8 +51,12 @@
4751
if (this.autoResize) {
4852
window.removeEventListener('resize', this.__resizeHanlder)
4953
}
50-
this.chart.dispose();
51-
this.chart = null;
54+
55+
const sidebarElm = document.getElementsByClassName('sidebar-container')[0]
56+
sidebarElm.removeEventListener('transitionend', this.__resizeHanlder)
57+
58+
this.chart.dispose()
59+
this.chart = null
5260
},
5361
methods: {
5462
initChart() {

0 commit comments

Comments
 (0)