zhangxiaoxu123456
2021-12-20 301289e539c417995f95f5cb91fd1f6043bb7cfd
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
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-row :justify="justify" @click="rowClick">
                    <u-col :span="span" :offset="offset" @click="click" stop>
                        <view class="demo-layout bg-purple-dark">
 
                        </view>
                    </u-col>
                    <u-col :span="span" :offset="offset">
                        <view class="demo-layout bg-purple-dark">
 
                        </view>
                    </u-col>
                    <u-col :span="span" :offset="offset">
                        <view class="demo-layout bg-purple-dark">
 
                        </view>
                    </u-col>
                </u-row>
            </view>
        </view>
        <view class="u-config-wrap">
            <view class="u-config-title u-border-bottom">
                参数配置
            </view>
            <view class="u-config-item">
                <view class="u-item-title">每个栅格占用栏数(演示共3个栅格)</view>
                <u-subsection :current="2" :list="[1, 2, 3, 4]" @change="spanChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">分栏偏移</view>
                <u-subsection :list="[0, 1, 2, 3]" @change="offsetChange"></u-subsection>
            </view>
            <!-- #ifndef MP -->
            <view class="u-config-item">
                <view class="u-item-title">水平排列方式(微信小程序无效)</view>
                <u-subsection :list="['start', 'end', 'around', 'between']" @change="justifyChange"></u-subsection>
            </view>
            <!-- #endif -->
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                span: 3,
                offset: 0,
                justify: 'start'
            }
        },
        methods: {
            click() {
                console.log('col click');
            },
            rowClick() {
                console.log('row click');
            },
            spanChange(e) {
                switch (e) {
                    case 0:
                        this.span = 1;
                        break;
                    case 1:
                        this.span = 2;
                        break;
                    case 2:
                        this.span = 3;
                        break;
                    case 3:
                        this.span = 4;
                        break;
                    case 4:
                        this.span = 5;
                        break;
                }
            },
            offsetChange(e) {
                switch (e) {
                    case 0:
                        this.offset = 0;
                        break;
                    case 1:
                        this.offset = 1;
                        break;
                    case 2:
                        this.offset = 2;
                        break;
                    case 3:
                        this.offset = 3;
                        break;
                }
            },
            justifyChange(e) {
                switch (e) {
                    case 0:
                        this.justify = 'start';
                        break;
                    case 1:
                        this.justify = 'end';
                        break;
                    case 2:
                        this.justify = 'around';
                        break;
                    case 3:
                        this.justify = 'between';
                        break;
                }
            },
        }
    }
</script>
 
<style scoped lang="scss">
    .demo-layout {
        height: 70rpx;
        border-radius: 8rpx;
        margin: 20rpx 0;
    }
 
    .bg-purple {
        background: #d3dce6;
    }
 
    .bg-purple-light {
        background: #e5e9f2;
    }
 
    .bg-purple-dark {
        background: #99a9bf;
    }
 
    // H5中,电脑端文档演示时,可能会导致演示块挤出边界,特别处理。
    // 真实使用环境不会产生此问题
    /* #ifdef H5 */
    .u-demo-area /deep/ .u-row {
        display: flex;
        flex-wrap: wrap;
    }
    /* #endif */
</style>