Blame view

src/components/card/card.vue 1.96 KB
15bae144   梁灏   add Card component
1
2
  <template>
      <div :class="classes">
743d0278   梁灏   update Card
3
4
          <div :class="headClasses" v-if="showHead"><slot name="title"></slot></div>
          <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
fb8a7b3f   young   style(card): feat...
5
          <div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
15bae144   梁灏   add Card component
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
      </div>
  </template>
  <script>
      const prefixCls = 'ivu-card';
  
      export default {
          props: {
              bordered: {
                  type: Boolean,
                  default: true
              },
              disHover: {
                  type: Boolean,
                  default: false
              },
              shadow: {
                  type: Boolean,
                  default: false
fb8a7b3f   young   style(card): feat...
24
              },
6d090ebf   young   style(card): padd...
25
              padding: Number
15bae144   梁灏   add Card component
26
27
28
29
30
          },
          data () {
              return {
                  showHead: true,
                  showExtra: true
b0893113   jingsam   :art: add eslint
31
              };
15bae144   梁灏   add Card component
32
33
34
35
36
37
38
39
40
41
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}`,
                      {
                          [`${prefixCls}-bordered`]: this.bordered && !this.shadow,
                          [`${prefixCls}-dis-hover`]: this.disHover || this.shadow,
                          [`${prefixCls}-shadow`]: this.shadow
                      }
b0893113   jingsam   :art: add eslint
42
                  ];
15bae144   梁灏   add Card component
43
44
45
46
47
48
49
50
51
              },
              headClasses () {
                  return `${prefixCls}-head`;
              },
              extraClasses () {
                  return `${prefixCls}-extra`;
              },
              bodyClasses () {
                  return `${prefixCls}-body`;
fb8a7b3f   young   style(card): feat...
52
53
              },
              bodyStyles () {
6d090ebf   young   style(card): padd...
54
55
56
                  let padding = this.padding
                  if (this.padding !== undefined) {
                      padding += 'px'
fb8a7b3f   young   style(card): feat...
57
                      return {
6d090ebf   young   style(card): padd...
58
                          padding
fb8a7b3f   young   style(card): feat...
59
60
61
                      };
                  }
                  return '';
15bae144   梁灏   add Card component
62
63
              }
          },
a8cb711c   huixisheng   Support Card
64
          mounted () {
743d0278   梁灏   update Card
65
66
              this.showHead = this.$slots.title !== undefined;
              this.showExtra = this.$slots.extra !== undefined;
15bae144   梁灏   add Card component
67
          }
b0893113   jingsam   :art: add eslint
68
69
      };
  </script>