Blame view

src/components/card/card.vue 2.36 KB
15bae144   梁灏   add Card component
1
2
  <template>
      <div :class="classes">
737e2df8   BillyWang   * Card组件增加title和i...
3
4
5
          <div :class="headClasses" v-if="showHead"><slot name="title">
              <p v-if="title"><Icon v-if="icon" :type="icon"></Icon>{{title}}</p>
          </slot></div>
743d0278   梁灏   update Card
6
          <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
fb8a7b3f   young   style(card): feat...
7
          <div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
15bae144   梁灏   add Card component
8
9
10
11
      </div>
  </template>
  <script>
      const prefixCls = 'ivu-card';
19d41352   梁灏   update Card
12
      const defaultPadding = 16;
737e2df8   BillyWang   * Card组件增加title和i...
13
      import Icon from '../icon/index'
15bae144   梁灏   add Card component
14
      export default {
6e2f40ea   Rijn   assign names to C...
15
          name: 'Card',
737e2df8   BillyWang   * Card组件增加title和i...
16
          components: { Icon },
15bae144   梁灏   add Card component
17
18
19
20
21
22
23
24
25
26
27
28
          props: {
              bordered: {
                  type: Boolean,
                  default: true
              },
              disHover: {
                  type: Boolean,
                  default: false
              },
              shadow: {
                  type: Boolean,
                  default: false
fb8a7b3f   young   style(card): feat...
29
              },
19d41352   梁灏   update Card
30
31
32
              padding: {
                  type: Number,
                  default: defaultPadding
737e2df8   BillyWang   * Card组件增加title和i...
33
34
35
36
37
38
              },
              title: {
                  type: String,
              },
              icon: {
                  type: String,
19d41352   梁灏   update Card
39
              }
15bae144   梁灏   add Card component
40
41
42
43
44
          },
          data () {
              return {
                  showHead: true,
                  showExtra: true
b0893113   jingsam   :art: add eslint
45
              };
15bae144   梁灏   add Card component
46
47
48
49
50
51
52
53
54
55
          },
          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
56
                  ];
15bae144   梁灏   add Card component
57
58
59
60
61
62
63
64
65
              },
              headClasses () {
                  return `${prefixCls}-head`;
              },
              extraClasses () {
                  return `${prefixCls}-extra`;
              },
              bodyClasses () {
                  return `${prefixCls}-body`;
fb8a7b3f   young   style(card): feat...
66
67
              },
              bodyStyles () {
19d41352   梁灏   update Card
68
                  if (this.padding !== defaultPadding) {
fb8a7b3f   young   style(card): feat...
69
                      return {
19d41352   梁灏   update Card
70
                          padding: `${this.padding}px`
ec4117cb   梁灏   tag add prop: name
71
                      };
19d41352   梁灏   update Card
72
73
                  } else {
                      return '';
fb8a7b3f   young   style(card): feat...
74
                  }
15bae144   梁灏   add Card component
75
76
              }
          },
a8cb711c   huixisheng   Support Card
77
          mounted () {
737e2df8   BillyWang   * Card组件增加title和i...
78
              this.showHead = this.title || this.$slots.title !== undefined;
743d0278   梁灏   update Card
79
              this.showExtra = this.$slots.extra !== undefined;
15bae144   梁灏   add Card component
80
          }
b0893113   jingsam   :art: add eslint
81
82
      };
  </script>