[Improvement] Layout: support flex (#1305)

This commit is contained in:
neverland
2018-06-19 22:54:02 +08:00
committed by GitHub
parent 6e25b9823a
commit c368e36aea
10 changed files with 321 additions and 120 deletions
+21 -2
View File
@@ -1,7 +1,15 @@
<template>
<div :class="b()" :style="style">
<component
:is="tag"
:class="b({
flex,
[`align-${align}`]: flex && align,
[`justify-${justify}`]: flex && justify
})"
:style="style"
>
<slot />
</div>
</component>
</template>
<script>
@@ -11,6 +19,13 @@ export default create({
name: 'row',
props: {
type: String,
align: String,
justify: String,
tag: {
type: String,
default: 'div'
},
gutter: {
type: [Number, String],
default: 0
@@ -18,6 +33,10 @@ export default create({
},
computed: {
flex() {
return this.type === 'flex';
},
style() {
const margin = `-${Number(this.gutter) / 2}px`;
return this.gutter