Commit b0a9eb4e2c7d1d7d7daa700a2be3f26c1fd4b0aa
Committed by
GitHub
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
src/components/card/card.vue
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <div :class="classes"> |
3 | 3 | <div :class="headClasses" v-if="showHead"><slot name="title"></slot></div> |
4 | 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 | 6 | </div> |
7 | 7 | </template> |
8 | 8 | <script> |
... | ... | @@ -21,7 +21,8 @@ |
21 | 21 | shadow: { |
22 | 22 | type: Boolean, |
23 | 23 | default: false |
24 | - } | |
24 | + }, | |
25 | + padding: Number | |
25 | 26 | }, |
26 | 27 | data () { |
27 | 28 | return { |
... | ... | @@ -48,6 +49,16 @@ |
48 | 49 | }, |
49 | 50 | bodyClasses () { |
50 | 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 | 64 | mounted () { | ... | ... |