Commit 737e2df88bec9a0f9b4f52dddf7b1c39950ee0e2

Authored by BillyWang
1 parent d45d2ee0

* Card组件增加title和icon属性,简化用户使用

Showing 1 changed file with 12 additions and 4 deletions   Show diff stats
src/components/card/card.vue
1 1 <template>
2 2 <div :class="classes">
3   - <div :class="headClasses" v-if="showHead"><slot name="title"></slot></div>
  3 + <div :class="headClasses" v-if="showHead"><slot name="title">
  4 + <p v-if="title"><Icon v-if="icon" :type="icon"></Icon>{{title}}</p>
  5 + </slot></div>
4 6 <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
5 7 <div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
6 8 </div>
... ... @@ -8,10 +10,10 @@
8 10 <script>
9 11 const prefixCls = 'ivu-card';
10 12 const defaultPadding = 16;
11   -
  13 + import Icon from '../icon/index'
12 14 export default {
13 15 name: 'Card',
14   -
  16 + components: { Icon },
15 17 props: {
16 18 bordered: {
17 19 type: Boolean,
... ... @@ -28,6 +30,12 @@
28 30 padding: {
29 31 type: Number,
30 32 default: defaultPadding
  33 + },
  34 + title: {
  35 + type: String,
  36 + },
  37 + icon: {
  38 + type: String,
31 39 }
32 40 },
33 41 data () {
... ... @@ -67,7 +75,7 @@
67 75 }
68 76 },
69 77 mounted () {
70   - this.showHead = this.$slots.title !== undefined;
  78 + this.showHead = this.title || this.$slots.title !== undefined;
71 79 this.showExtra = this.$slots.extra !== undefined;
72 80 }
73 81 };
... ...