Rap 原分销系统代码Web
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

56 wiersze
1.5KB

  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. }