zhangwei
2024-08-27 71d2e42ae642cecb5e8f6776c702cd20bafe6c01
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
    <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:16  3,营业执照号: 9151  0131          3 32006  1 93K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
    <view class="fui-row__box" :class="[flex?'fui-row__flex':'', justifyClass,alignClass]" :style="{marginTop:marginTop,marginBottom:marginBottom,marginLeft:`-${marginValue}rpx`,
        marginRight:`-${marginValue}rpx`}">
        <slot></slot>
    </view>
</template>
 
<script>
    export default {
        name: "fui-row",
        componentName: 'fuiRow',
        props: {
            //是否为flex布局
            isFlex: {
                type: Boolean,
                default: false
            },
            //flex 布局下的水平排列方式 start/end/center/space-around/space-between
            justify: {
                type: String,
                default: 'start'
            },
            //flex 布局下的垂直排列方式    top/middle/bottom
            align: {
                type: String,
                default: 'top'
            },
            marginTop: {
                type: String,
                default: '0'
            },
            marginBottom: {
                type: String,
                default: '0'
            },
            //栅格间隔
            gutter: {
                type: Number,
                default: 0
            },
            // nvue如果使用span等属性,需要配置宽度
            width: {
                type: [String, Number],
                default: 750
            }
        },
        data() {
            return {
                flex: false
            }
        },
        watch: {
            isFlex(val) {
                // #ifndef APP-NVUE
                this.flex = val;
                // #endif
            }
        },
        created() {
            // #ifndef APP-NVUE
            this.flex = this.isFlex;
            // #endif
            // #ifdef APP-NVUE
            this.flex = true;
            // #endif
        },
        computed: {
            marginValue() {
                // #ifndef APP-NVUE
                if (this.gutter) {
                    return Number(this.gutter) / 2;
                }
                // #endif
                return 0;
            },
            justifyClass() {
                return this.justify !== 'start' ? `fui-row__${this.justify}` : ''
            },
            alignClass() {
                return this.align !== 'top' ? `fui-row__${this.align}` : ''
            }
        }
    }
</script>
 
<style scoped>
    /* #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ */
    :host {
        position: relative;
        box-sizing: border-box;
        display: block;
    }
 
    /* #endif */
 
    .fui-row__box {
        /* #ifdef APP-NVUE */
        flex: 1;
        /* #endif */
        /* #ifndef APP-NVUE */
        box-sizing: border-box;
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        /* #endif */
        position: relative;
        /* #ifdef MP-TOUTIAO || MP-QQ || MP-BAIDU */
        display: block;
        /* #endif */
        flex-direction: row;
    }
 
    /* #ifndef APP-NVUE */
    .fui-row__box::before {
        display: table;
        content: " ";
    }
 
    .fui-row__box::after {
        display: table;
        content: " ";
    }
 
    .fui-row__box::after {
        clear: both;
    }
 
    /* #endif */
    .fui-row__flex {
        /* #ifndef APP-NVUE*/
        display: flex;
        /* #endif */
        flex-direction: row;
    }
 
    .fui-row__middle {
        align-items: center;
    }
 
    .fui-row__bottom {
        align-items: flex-end;
    }
 
    /* #ifndef APP-NVUE */
    .fui-row__before {
        display: table
    }
 
    /* #endif */
 
    .fui-row__end {
        justify-content: flex-end;
    }
 
    .fui-row__center {
        justify-content: center;
    }
 
    .fui-row__space-around {
        justify-content: space-around;
    }
 
    .fui-row__space-between {
        justify-content: space-between;
    }
</style>