Rap 原分销系统代码Web
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.

8ff3cd8f6d581efb2ac2b16bbb3fc6ff8c9bd4f3.svn-base 1.5KB

5 mesi fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { debounce } from '@/utils'
  2. export default {
  3. data() {
  4. return {
  5. $_sidebarElm: null,
  6. $_resizeHandler: null
  7. }
  8. },
  9. mounted() {
  10. this.$_resizeHandler = debounce(() => {
  11. if (this.chart) {
  12. this.chart.resize()
  13. }
  14. }, 100)
  15. this.$_initResizeEvent()
  16. this.$_initSidebarResizeEvent()
  17. },
  18. beforeDestroy() {
  19. this.$_destroyResizeEvent()
  20. this.$_destroySidebarResizeEvent()
  21. },
  22. // to fixed bug when cached by keep-alive
  23. // https://github.com/PanJiaChen/vue-element-admin/issues/2116
  24. activated() {
  25. this.$_initResizeEvent()
  26. this.$_initSidebarResizeEvent()
  27. },
  28. deactivated() {
  29. this.$_destroyResizeEvent()
  30. this.$_destroySidebarResizeEvent()
  31. },
  32. methods: {
  33. // use $_ for mixins properties
  34. // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
  35. $_initResizeEvent() {
  36. window.addEventListener('resize', this.$_resizeHandler)
  37. },
  38. $_destroyResizeEvent() {
  39. window.removeEventListener('resize', this.$_resizeHandler)
  40. },
  41. $_sidebarResizeHandler(e) {
  42. if (e.propertyName === 'width') {
  43. this.$_resizeHandler()
  44. }
  45. },
  46. $_initSidebarResizeEvent() {
  47. this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
  48. this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
  49. },
  50. $_destroySidebarResizeEvent() {
  51. this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
  52. }
  53. }
  54. }