Blame view

src/components/tabs/pane.vue 1.82 KB
871ed4d8   梁灏   init Tabs component
1
  <template>
68335adb   梁灏   fix #5111 , close...
2
      <div :class="prefixCls" v-show="show" :style="contentStyle"><slot></slot></div>
871ed4d8   梁灏   init Tabs component
3
4
  </template>
  <script>
17f52abf   梁灏   update Tabs
5
6
      const prefixCls = 'ivu-tabs-tabpane';
  
871ed4d8   梁灏   init Tabs component
7
      export default {
17f52abf   梁灏   update Tabs
8
          name: 'TabPane',
4d8b4016   梁灏   update Tabs metho...
9
          inject: ['TabsInstance'],
17f52abf   梁灏   update Tabs
10
          props: {
30510c3d   梁灏   support Tabs
11
              name: {
17f52abf   梁灏   update Tabs
12
13
14
                  type: String
              },
              label: {
bef89707   Aresn   update tabs
15
                  type: [String, Function],
17f52abf   梁灏   update Tabs
16
17
18
19
20
21
22
23
                  default: ''
              },
              icon: {
                  type: String
              },
              disabled: {
                  type: Boolean,
                  default: false
7a737482   梁灏   fixed #206
24
25
26
27
              },
              closable: {
                  type: Boolean,
                  default: null
26b2cfa0   梁灏   fixed #5377
28
29
30
31
32
              },
              // Tabs 嵌套时,用 tab 区分层级,指向对应的 Tabs 的 name
              tab: {
                  type: String
              },
17f52abf   梁灏   update Tabs
33
          },
871ed4d8   梁灏   init Tabs component
34
          data () {
17f52abf   梁灏   update Tabs
35
36
              return {
                  prefixCls: prefixCls,
30510c3d   梁灏   support Tabs
37
38
                  show: true,
                  currentName: this.name
b0893113   jingsam   :art: add eslint
39
              };
17f52abf   梁灏   update Tabs
40
          },
68335adb   梁灏   fix #5111 , close...
41
42
43
          computed: {
              contentStyle () {
                  return {
4d8b4016   梁灏   update Tabs metho...
44
                      visibility: this.TabsInstance.activeKey !== this.currentName ? 'hidden' : 'visible'
68335adb   梁灏   fix #5111 , close...
45
46
47
                  };
              }
          },
17f52abf   梁灏   update Tabs
48
49
          methods: {
              updateNav () {
4d8b4016   梁灏   update Tabs metho...
50
                  this.TabsInstance.updateNav();
17f52abf   梁灏   update Tabs
51
              }
871ed4d8   梁灏   init Tabs component
52
          },
17f52abf   梁灏   update Tabs
53
          watch: {
30510c3d   梁灏   support Tabs
54
55
56
57
              name (val) {
                  this.currentName = val;
                  this.updateNav();
              },
17f52abf   梁灏   update Tabs
58
59
60
61
62
63
64
65
66
              label () {
                  this.updateNav();
              },
              icon () {
                  this.updateNav();
              },
              disabled () {
                  this.updateNav();
              }
420ef343   梁灏   fixed #155
67
          },
30510c3d   梁灏   support Tabs
68
          mounted () {
420ef343   梁灏   fixed #155
69
              this.updateNav();
c2d74eca   梁灏   fixed #2100
70
71
72
          },
          destroyed () {
              this.updateNav();
17f52abf   梁灏   update Tabs
73
          }
b0893113   jingsam   :art: add eslint
74
75
      };
  </script>