fix:dashboard页面图表resize的防抖并没有防住抖动 (#2586)
This commit is contained in:
		@@ -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 {
 | 
				
			|||||||
  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)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user