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
<!--
 * @Desc: ---   ----
 * @Date: 2020-04-22 12:29:21
 * @LastEditors: 王
 * @LastEditTime: 2020-04-22 18:33:28
 -->
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
            </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">背景颜色</view>
                <u-subsection :list="['default', 'primary', 'error', 'warning', 'success']" @change="bgColorChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">高度</view>
                <u-subsection :list="['30', '50', '70']" @change="heightChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">上下外边距</view>
                <u-subsection :list="['30', '50', '70']" @change="marginChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
export default {
    data() {
        return {
            height: 30,
            bgColor: this.$u.color.bgColor,
            marginTop: 30,
            marginBottom: 30
        };
    },
    methods: {
        bgColorChange(index) {
            let color = index == 0 ? 'default' : index == 1 ? 'primary' : index == 2 ? 'error' : index == 3 ? 'warning' : 'success';
            this.bgColor = color == 'default' ? this.$u.color['bgColor'] : this.$u.color[color];
        },
        heightChange(index) {
            this.height = index == 0 ? 30 : index == 1 ? 50 : 70;
        },
        marginChange(index) {
            this.marginTop = ['30', '50', '70'][index];
            this.marginBottom = this.marginTop;
        }
    }
};
</script>
 
<style lang="scss" scoped>
.wrap {
    padding: 24rpx;
}
</style>