baotian
2024-06-04 b959135a1139fb66646523d92e5bd20c5910f283
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <div class="home-index-page" ref="page" >
    <!-- <div class="com"><module-a /></div> -->
    <div class="divider"></div>
    <div class="com"><module-b /></div>
  </div>
</template>
 
<script>
import ModuleA from './ModuleA.vue'
import ModuleB from './ModuleB.vue'
import ModuleC from './ModuleC.vue'
export default {
  name: 'HomeIndexPage',
  components: { ModuleA, ModuleB, ModuleC },
  data() {
    return {
      pageHeight: '100%'
    }
  },
  watch: {
    '$store.state.app.multiTab': {
      deep: true,
      handler: (newVal, oldVal) => {
        this.calPageHeight(newVal)
      }
    }
  },
  methods: {
    calPageHeight(hasTab) {
      if (hasTab) {
       const _h = this.$refs.page.clientHeight
       if (_h) {
         this.pageHeight = (_h - 42) + 'px'
       }
      } else {
        this.pageHeight = '100%'
      }
    },
    initPageHeight(callback) {
      setTimeout(() => {
        this.calPageHeight(this.$store.state.app.multiTab)
        callback && callback()
      }, 100)
    }
  },
  mounted() {
    this.initPageHeight()
  }
}
</script>
 
<style lang="less" scoped>
.home-index-page{
  display: flex;
  flex-direction:column;
 
  .com{
    flex:1;
  }
 
  .divider{
    height: 10px;
  }
}
</style>