zhangxiaoxu123456
2021-12-06 f32f7d699607bb159d25dcf441942370aba2c968
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
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-number-box v-model="value" :bg-color="bgColor" :color="color" :min="0"
                :step="step" :disabled="disabled" @change="change" @focus="focus"></u-number-box>
            </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="[1, 5, 18]" @change="valueChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">自定义样式</view>
                <u-subsection current="1" :list="['是', '否']" @change="styleChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">是否禁用</view>
                <u-subsection current="1" :list="['是', '否']" @change="disabledChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">步进值</view>
                <u-subsection :list="[1, 3, 5, 8]" @change="stepChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
export default {
    data() {
        return {
            value: 1,
            bgColor: "#F2F3F5",
            color: '#323233',
            disabled: false,
            step: 1,
            
        };
    },
    methods: {
        valueChange(index) {
            this.value = index == 0 ? 1 : index == 1 ? 5 : 18;
        },
        styleChange(index) {
            if(index == 0) {
                this.bgColor = '#ff6d00';
                this.color = '#fff';
            } else {
                this.bgColor = "#F2F3F5";
                this.color = '#323233';
            }
        },
        disabledChange(index) {
            this.disabled = index == 0 ? true : false;
        },
        stepChange(index) {
            this.step = index == 0 ? 1 : index == 1 ? 3 : index == 2 ? 5 : 8;
        },
        change(e) {
            //console.log(e.value);
        },
        focus() {
            console.log('focus');
        }
    }
};
</script>
 
<style lang="scss" scoped>
.u-demo {}
</style>