Blame view

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