perf[Charts]: add resize mixin

This commit is contained in:
Pan
2018-03-13 18:36:11 +08:00
parent a633729215
commit c398ee0ddc
4 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import { debounce } from '@/utils'
export default {
mounted() {
this.__resizeHanlder = debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)
window.addEventListener('resize', this.__resizeHanlder)
},
beforeDestroy() {
window.removeEventListener('resize', this.__resizeHanlder)
}
}