7fa943eb
梁灏
init
|
1
|
<template>
|
d2203972
梁灏
add gutter to Row...
|
2
|
<div :class="classes" :style="styles">
|
7fa943eb
梁灏
init
|
3
4
5
6
|
<slot></slot>
</div>
</template>
<script>
|
ce7b39c2
梁灏
fixed #3596
|
7
|
import { oneOf, findComponentDownward, findBrothersComponents } from '../../utils/assist';
|
7fa943eb
梁灏
init
|
8
9
10
11
|
const prefixCls = 'ivu-row';
export default {
|
34ee7b4a
梁灏
support Tree & ad...
|
12
|
name: 'Row',
|
7fa943eb
梁灏
init
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
props: {
type: {
validator (value) {
return oneOf(value, ['flex']);
}
},
align: {
validator (value) {
return oneOf(value, ['top', 'middle', 'bottom']);
}
},
justify: {
validator (value) {
return oneOf(value, ['start', 'end', 'center', 'space-around', 'space-between']);
}
},
|
d2203972
梁灏
add gutter to Row...
|
29
30
31
32
|
gutter: {
type: Number,
default: 0
},
|
7fa943eb
梁灏
init
|
33
34
35
36
37
|
className: String
},
computed: {
classes () {
return [
|
7fa943eb
梁灏
init
|
38
|
{
|
9d844d53
梁灏
fixed Layout bug
|
39
|
[`${prefixCls}`]: !this.type,
|
7fa943eb
梁灏
init
|
40
41
42
43
44
|
[`${prefixCls}-${this.type}`]: !!this.type,
[`${prefixCls}-${this.type}-${this.align}`]: !!this.align,
[`${prefixCls}-${this.type}-${this.justify}`]: !!this.justify,
[`${this.className}`]: !!this.className
}
|
b0893113
jingsam
add eslint
|
45
|
];
|
d2203972
梁灏
add gutter to Row...
|
46
47
48
49
50
51
52
|
},
styles () {
let style = {};
if (this.gutter !== 0) {
style = {
marginLeft: this.gutter / -2 + 'px',
marginRight: this.gutter / -2 + 'px'
|
b0893113
jingsam
add eslint
|
53
|
};
|
d2203972
梁灏
add gutter to Row...
|
54
55
56
|
}
return style;
|
7fa943eb
梁灏
init
|
57
|
}
|
d2203972
梁灏
add gutter to Row...
|
58
59
60
|
},
methods: {
updateGutter (val) {
|
ce7b39c2
梁灏
fixed #3596
|
61
62
63
64
|
// 这里会嵌套寻找,把 Col 里的 Row 里的 Col 也找到,所以用 兄弟找
// const Cols = findComponentsDownward(this, 'iCol');
const Col = findComponentDownward(this, 'iCol');
const Cols = findBrothersComponents(Col, 'iCol', false);
|
9eec7f16
梁灏
fixed #1661
|
65
66
67
68
69
70
71
|
if (Cols.length) {
Cols.forEach((child) => {
if (val !== 0) {
child.gutter = val;
}
});
}
|
d2203972
梁灏
add gutter to Row...
|
72
73
74
75
76
77
|
}
},
watch: {
gutter (val) {
this.updateGutter(val);
}
|
7fa943eb
梁灏
init
|
78
|
}
|
b0893113
jingsam
add eslint
|
79
80
|
};
</script>
|