Commit b0a9eb4e2c7d1d7d7daa700a2be3f26c1fd4b0aa

Authored by Aresn
Committed by GitHub
2 parents 85ed4df8 91f3d3ff

Merge pull request #429 from muei/2.0

style(card): feat padding switch prop
Showing 2 changed files with 14 additions and 3 deletions   Show diff stats
examples/routers/card.vue
1 <template> 1 <template>
2 - <Card style="width:350px"> 2 + <Card style="width:350px" v-bind:padding="0">
3 <p slot="title"> 3 <p slot="title">
4 <Icon type="ios-film-outline"></Icon> 4 <Icon type="ios-film-outline"></Icon>
5 经典电影 5 经典电影
src/components/card/card.vue
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div :class="classes"> 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"></slot></div>
4 <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div> 4 <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
5 - <div :class="bodyClasses"><slot></slot></div> 5 + <div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
6 </div> 6 </div>
7 </template> 7 </template>
8 <script> 8 <script>
@@ -21,7 +21,8 @@ @@ -21,7 +21,8 @@
21 shadow: { 21 shadow: {
22 type: Boolean, 22 type: Boolean,
23 default: false 23 default: false
24 - } 24 + },
  25 + padding: Number
25 }, 26 },
26 data () { 27 data () {
27 return { 28 return {
@@ -48,6 +49,16 @@ @@ -48,6 +49,16 @@
48 }, 49 },
49 bodyClasses () { 50 bodyClasses () {
50 return `${prefixCls}-body`; 51 return `${prefixCls}-body`;
  52 + },
  53 + bodyStyles () {
  54 + let padding = this.padding;
  55 + if (this.padding !== undefined) {
  56 + padding += 'px';
  57 + return {
  58 + padding,
  59 + };
  60 + }
  61 + return '';
51 } 62 }
52 }, 63 },
53 mounted () { 64 mounted () {