index.vue
1.2 KB
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
<template>
<uni-shadow-root class="vant-dist-row-index"><view class="custom-class van-row" :style="viewStyle">
<slot></slot>
</view></uni-shadow-root>
</template>
<script>
global['__wxRoute'] = 'vant/dist/row/index'
import { VantComponent } from '../common/component';
VantComponent({
relation: {
name: 'col',
type: 'descendant',
current: 'row',
linked(target) {
if (this.data.gutter) {
target.setGutter(this.data.gutter);
}
},
},
props: {
gutter: {
type: Number,
observer: 'setGutter',
},
},
data: {
viewStyle: '',
},
mounted() {
if (this.data.gutter) {
this.setGutter();
}
},
methods: {
setGutter() {
const { gutter } = this.data;
const margin = `-${Number(gutter) / 2}px`;
const viewStyle = gutter
? `margin-right: ${margin}; margin-left: ${margin};`
: '';
this.setData({ viewStyle });
this.getRelationNodes('../col/index').forEach((col) => {
col.setGutter(this.data.gutter);
});
},
},
});
export default global['__wxComponents']['vant/dist/row/index']
</script>
<style platform="mp-weixin">
@import '../common/index.css';.van-row:after{display:table;clear:both;content:""}
</style>