1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| <template>
| <div :class="classes" :style="styles">
| <slot></slot>
| </div>
| </template>
| <script>
| import { oneOf, findComponentDownward, findBrothersComponents } from '../../utils/assist';
|
| const prefixCls = 'ivu-row';
|
| export default {
| name: 'Row',
| props: {
| // todo 4.5.0 已无效,强制 flex
| 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']);
| }
| },
| gutter: {
| type: Number,
| default: 0
| },
| className: String,
| // 4.5.0
| wrap: {
| type: Boolean,
| default: true
| }
| },
| computed: {
| classes () {
| return [
| // todo 4.5.0 已无效,强制 flex
| `${prefixCls}`,
| {
| [`${prefixCls}-${this.type}`]: !!this.type,
| [`${prefixCls}-${this.type}-${this.align}`]: !!this.align && this.type,
| [`${prefixCls}-${this.type}-${this.justify}`]: !!this.justify && this.type,
| [`${prefixCls}-${this.align}`]: !!this.align,
| [`${prefixCls}-${this.justify}`]: !!this.justify,
| [`${this.className}`]: !!this.className,
| [`${prefixCls}-no-wrap`]: !this.wrap
| }
| ];
| },
| styles () {
| let style = {};
| if (this.gutter !== 0) {
| style = {
| marginLeft: this.gutter / -2 + 'px',
| marginRight: this.gutter / -2 + 'px'
| };
| }
|
| return style;
| }
| },
| methods: {
| updateGutter (val) {
| // 这里会嵌套寻找,把 Col 里的 Row 里的 Col 也找到,所以用 兄弟找
| // const Cols = findComponentsDownward(this, 'iCol');
| const Col = findComponentDownward(this, 'iCol');
| const Cols = findBrothersComponents(Col, 'iCol', false);
| if (Cols.length) {
| Cols.forEach((child) => {
| if (val !== 0) {
| child.gutter = val;
| }
| });
| }
| }
| },
| watch: {
| gutter (val) {
| this.updateGutter(val);
| }
| }
| };
| </script>
|
|