提交 1336b92c 编写于 作者: M MaYuanhai 提交者: 花裤衩

fix[Dashboard]: fixed debounce bug (#2586) (#2597)

To fixed https://github.com/PanJiaChen/vue-element-admin/issues/2586
上级 c7c815ee
...@@ -3,10 +3,16 @@ import { debounce } from '@/utils' ...@@ -3,10 +3,16 @@ import { debounce } from '@/utils'
export default { export default {
data() { data() {
return { return {
$_sidebarElm: null $_sidebarElm: null,
$_resizeHandler: null
} }
}, },
mounted() { mounted() {
this.$_resizeHandler = debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)
this.$_initResizeEvent() this.$_initResizeEvent()
this.$_initSidebarResizeEvent() this.$_initSidebarResizeEvent()
}, },
...@@ -27,13 +33,6 @@ export default { ...@@ -27,13 +33,6 @@ export default {
methods: { methods: {
// use $_ for mixins properties // use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_resizeHandler() {
return debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)()
},
$_initResizeEvent() { $_initResizeEvent() {
window.addEventListener('resize', this.$_resizeHandler) window.addEventListener('resize', this.$_resizeHandler)
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册