mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-09-08 11:26:24 +08:00
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…
x
Reference in New Issue
Block a user