Blame view

src/components/collapse/panel.vue 1.56 KB
49306c7a   梁灏   add Collapse comp...
1
2
3
4
5
6
  <template>
      <div :class="itemClasses">
          <div :class="headerClasses" @click="toggle">
              <Icon type="arrow-right-b"></Icon>
              <slot></slot>
          </div>
a190ce84   梁灏   support Collapse
7
          <div :class="contentClasses" v-show="isActive">
49306c7a   梁灏   add Collapse comp...
8
9
10
11
12
              <div :class="boxClasses"><slot name="content"></slot></div>
          </div>
      </div>
  </template>
  <script>
b923c818   梁灏   update Tree
13
      import Icon from '../icon/icon.vue';
49306c7a   梁灏   add Collapse comp...
14
15
16
      const prefixCls = 'ivu-collapse';
  
      export default {
34ee7b4a   梁灏   support Tree & ad...
17
          name: 'Panel',
49306c7a   梁灏   add Collapse comp...
18
19
          components: { Icon },
          props: {
a190ce84   梁灏   support Collapse
20
              name: {
49306c7a   梁灏   add Collapse comp...
21
22
23
24
25
                  type: String
              }
          },
          data () {
              return {
a190ce84   梁灏   support Collapse
26
                  index: 0, // use index for default when name is null
49306c7a   梁灏   add Collapse comp...
27
                  isActive: false
b0893113   jingsam   :art: add eslint
28
              };
49306c7a   梁灏   add Collapse comp...
29
30
31
32
33
34
35
36
          },
          computed: {
              itemClasses () {
                  return [
                      `${prefixCls}-item`,
                      {
                          [`${prefixCls}-item-active`]: this.isActive
                      }
b0893113   jingsam   :art: add eslint
37
                  ];
49306c7a   梁灏   add Collapse comp...
38
39
40
41
              },
              headerClasses () {
                  return `${prefixCls}-header`;
              },
a190ce84   梁灏   support Collapse
42
              contentClasses () {
49306c7a   梁灏   add Collapse comp...
43
44
45
46
47
48
49
50
                  return `${prefixCls}-content`;
              },
              boxClasses () {
                  return `${prefixCls}-content-box`;
              }
          },
          methods: {
              toggle () {
a190ce84   梁灏   support Collapse
51
                  // todo while向上查找
49306c7a   梁灏   add Collapse comp...
52
                  this.$parent.toggle({
a190ce84   梁灏   support Collapse
53
                      name: this.name || this.index,
49306c7a   梁灏   add Collapse comp...
54
55
56
57
                      isActive: this.isActive
                  });
              }
          }
b0893113   jingsam   :art: add eslint
58
59
      };
  </script>