Blame view

src/components/collapse/panel.vue 1.91 KB
49306c7a   梁灏   add Collapse comp...
1
2
3
  <template>
      <div :class="itemClasses">
          <div :class="headerClasses" @click="toggle">
67373f38   梁灏   update Collapse I...
4
              <Icon type="ios-arrow-forward" v-if="!hideArrow"></Icon>
49306c7a   梁灏   add Collapse comp...
5
6
              <slot></slot>
          </div>
bbc31581   梁灏   Optimize Collapse...
7
          <collapse-transition v-if="mounted">
b80c48ff   Aresn   Collapse support ...
8
9
10
11
              <div :class="contentClasses" v-show="isActive">
                  <div :class="boxClasses"><slot name="content"></slot></div>
              </div>
          </collapse-transition>
49306c7a   梁灏   add Collapse comp...
12
13
14
      </div>
  </template>
  <script>
b923c818   梁灏   update Tree
15
      import Icon from '../icon/icon.vue';
b80c48ff   Aresn   Collapse support ...
16
      import CollapseTransition from '../base/collapse-transition';
49306c7a   梁灏   add Collapse comp...
17
18
19
      const prefixCls = 'ivu-collapse';
  
      export default {
34ee7b4a   梁灏   support Tree & ad...
20
          name: 'Panel',
b80c48ff   Aresn   Collapse support ...
21
          components: { Icon, CollapseTransition },
49306c7a   梁灏   add Collapse comp...
22
          props: {
a190ce84   梁灏   support Collapse
23
              name: {
49306c7a   梁灏   add Collapse comp...
24
                  type: String
0c9f8fab   梁灏   Collapse add hide...
25
26
27
28
              },
              hideArrow: {
                  type: Boolean,
                  default: false
49306c7a   梁灏   add Collapse comp...
29
30
31
32
              }
          },
          data () {
              return {
a190ce84   梁灏   support Collapse
33
                  index: 0, // use index for default when name is null
bbc31581   梁灏   Optimize Collapse...
34
35
                  isActive: false,
                  mounted: false
b0893113   jingsam   :art: add eslint
36
              };
49306c7a   梁灏   add Collapse comp...
37
38
39
40
41
42
43
44
          },
          computed: {
              itemClasses () {
                  return [
                      `${prefixCls}-item`,
                      {
                          [`${prefixCls}-item-active`]: this.isActive
                      }
b0893113   jingsam   :art: add eslint
45
                  ];
49306c7a   梁灏   add Collapse comp...
46
47
48
49
              },
              headerClasses () {
                  return `${prefixCls}-header`;
              },
a190ce84   梁灏   support Collapse
50
              contentClasses () {
49306c7a   梁灏   add Collapse comp...
51
52
53
54
55
56
57
58
                  return `${prefixCls}-content`;
              },
              boxClasses () {
                  return `${prefixCls}-content-box`;
              }
          },
          methods: {
              toggle () {
49306c7a   梁灏   add Collapse comp...
59
                  this.$parent.toggle({
a190ce84   梁灏   support Collapse
60
                      name: this.name || this.index,
49306c7a   梁灏   add Collapse comp...
61
62
63
                      isActive: this.isActive
                  });
              }
bbc31581   梁灏   Optimize Collapse...
64
65
66
          },
          mounted () {
              this.mounted = true;
49306c7a   梁灏   add Collapse comp...
67
          }
b0893113   jingsam   :art: add eslint
68
69
      };
  </script>