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
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <view class="u-demo-result-line">
                    {{result}}
                </view>
            </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">GRB转HEX</view>
                <u-subsection :list="['rgb(12,57,231)', 'rgb(15,148,32)', 'rgb(91,52,210)']" @change="rgbToHexChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">HEX转GRB</view>
                <u-subsection :list="['#0edc8a', '#d0a73c', '#3308dd']" @change="hexToRgbChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">颜色渐变(rgb(21,21,21)-rgb(56,56,56),分10份)</view>
                <u-button @click="colorGradientChange">执行</u-button>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                result: null
            }
        },
        onLoad() {
            this.result = this.$u.rgbToHex('rgb(12,57,231)')
        },
        methods: {
            rgbToHexChange(index) {
                let color = index == 0 ? 'rgb(12,57,231)' : index == 1 ? 'rgb(15,148,32)' : 'rgb(91,52,210)';
                this.result = this.$u.rgbToHex(color)
            },
            hexToRgbChange(index) {
                let color = index == 0 ? '#0edc8a' : index == 1 ? '#d0a73c' : '#3308dd';
                this.result = this.$u.hexToRgb(color)
            },
            colorGradientChange(index) { 
                this.result = JSON.stringify(this.$u.colorGradient('rgb(21,21,21)', 'rgb(56,56,56)', 10))
            },
            getResult() {
                this.result = this.$u.guid(this.length, this.firstU, this.radix);
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .u-demo {}
</style>