You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
839 B

6 years ago
import {debounce} from '@/utils'
export default {
data() {
return {
$_sidebarElm: null,
$_resizeHandler: null
}
},
methods: {
$_initResizeEvent() {
window.addEventListener('resize', this.$_resizeHandler)
},
$_destroyResizeEvent() {
window.removeEventListener('resize', this.$_resizeHandler)
}
},
mounted() {
this.$_resizeHandler = debounce(() => this.chart && this.chart.resize())
this.$_initResizeEvent()
this.$nextTick(() => this.$_resizeHandler())
},
beforeDestroy() {
this.$_destroyResizeEvent()
},
activated() {
this.$_initResizeEvent()
this.$nextTick(() => this.$_resizeHandler())
},
deactivated() {
this.$_destroyResizeEvent()
}
}