rewrite the code to make it elegant
This commit is contained in:
parent
fd1bdec706
commit
4b2bfd5610
|
@ -10,16 +10,12 @@ export default {
|
|||
window.addEventListener('resize', this.__resizeHandler)
|
||||
|
||||
this.sidebarElm = document.getElementsByClassName('sidebar-container')[0]
|
||||
if (this.sidebarElm) {
|
||||
this.sidebarElm.addEventListener('transitionend', this.sidebarResizeHandler)
|
||||
}
|
||||
this.sidebarElm && this.sidebarElm.addEventListener('transitionend', this.sidebarResizeHandler)
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.__resizeHandler)
|
||||
|
||||
if (this.sidebarElm) {
|
||||
this.sidebarElm.removeEventListener('transitionend', this.sidebarResizeHandler)
|
||||
}
|
||||
this.sidebarElm && this.sidebarElm.removeEventListener('transitionend', this.sidebarResizeHandler)
|
||||
},
|
||||
methods: {
|
||||
sidebarResizeHandler(e) {
|
||||
|
|
|
@ -56,9 +56,7 @@ export default {
|
|||
|
||||
// 监听侧边栏的变化
|
||||
this.sidebarElm = document.getElementsByClassName('sidebar-container')[0]
|
||||
if (this.sidebarElm) {
|
||||
this.sidebarElm.addEventListener('transitionend', this.sidebarResizeHandler)
|
||||
}
|
||||
this.sidebarElm && this.sidebarElm.addEventListener('transitionend', this.sidebarResizeHandler)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (!this.chart) {
|
||||
|
@ -68,9 +66,7 @@ export default {
|
|||
window.removeEventListener('resize', this.__resizeHandler)
|
||||
}
|
||||
|
||||
if (this.sidebarElm) {
|
||||
this.sidebarElm.removeEventListener('transitionend', this.sidebarResizeHandler)
|
||||
}
|
||||
this.sidebarElm && this.sidebarElm.removeEventListener('transitionend', this.sidebarResizeHandler)
|
||||
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
|
|
Loading…
Reference in New Issue