Blame view

src/components/collapse/panel.vue 1.8 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>
b80c48ff   Aresn   Collapse support ...
7
8
9
10
11
          <collapse-transition>
              <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
49306c7a   梁灏   add Collapse comp...
34
                  isActive: false
b0893113   jingsam   :art: add eslint
35
              };
49306c7a   梁灏   add Collapse comp...
36
37
38
39
40
41
42
43
          },
          computed: {
              itemClasses () {
                  return [
                      `${prefixCls}-item`,
                      {
                          [`${prefixCls}-item-active`]: this.isActive
                      }
b0893113   jingsam   :art: add eslint
44
                  ];
49306c7a   梁灏   add Collapse comp...
45
46
47
48
              },
              headerClasses () {
                  return `${prefixCls}-header`;
              },
a190ce84   梁灏   support Collapse
49
              contentClasses () {
49306c7a   梁灏   add Collapse comp...
50
51
52
53
54
55
56
57
                  return `${prefixCls}-content`;
              },
              boxClasses () {
                  return `${prefixCls}-content-box`;
              }
          },
          methods: {
              toggle () {
49306c7a   梁灏   add Collapse comp...
58
                  this.$parent.toggle({
a190ce84   梁灏   support Collapse
59
                      name: this.name || this.index,
49306c7a   梁灏   add Collapse comp...
60
61
62
63
                      isActive: this.isActive
                  });
              }
          }
b0893113   jingsam   :art: add eslint
64
65
      };
  </script>