DrawerTabsContainer.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div :class="[idDrawerTabs?'dtc-main':'']" :style="myStyle">
  3. <div :class="[idDrawerTabs?'dtc-body':'']">
  4. <slot/>
  5. </div>
  6. </div>
  7. </template>
  8. <style lang="scss" scoped>
  9. .dtc-main {
  10. display: flex;
  11. flex-direction: column;
  12. width: 100%;
  13. overflow: hidden;
  14. position: relative;
  15. transform: translateZ(0);
  16. .dtc-body {
  17. position: absolute;
  18. left: 0;
  19. right: 0;
  20. top: 0;
  21. bottom: 0;
  22. width: 100%;
  23. height: 100%;
  24. overflow: auto;
  25. }
  26. }
  27. </style>
  28. <script>
  29. export default {
  30. name: 'DrawerTabsContainer',
  31. data() {
  32. return {
  33. idDrawerTabs: false,
  34. calculateHeight: 0,
  35. }
  36. },
  37. mounted() {
  38. let el = $A(this.$el);
  39. let eb = el.parents(".ivu-drawer-body");
  40. if (eb == 0 || eb.parents(".ivu-drawer-wrap").length == 0) {
  41. return;
  42. }
  43. this.idDrawerTabs = true;
  44. this.calculateHeight = Math.round(eb.outerHeight() - el.offset().top);
  45. setInterval(() => {
  46. this.calculateHeight = Math.round(eb.outerHeight() - el.offset().top);
  47. }, 300);
  48. },
  49. computed: {
  50. myStyle() {
  51. const {calculateHeight, idDrawerTabs} = this;
  52. if (!idDrawerTabs) {
  53. return {};
  54. }
  55. return {
  56. height: Math.max(0, calculateHeight - 16) + 'px'
  57. }
  58. }
  59. },
  60. }
  61. </script>