cdk
2025-03-24 06e6cf5719a7de9d7919cee2f6fcc3cfc6f9eb9d
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
<template>
    <view class="uni-layout-row" :class="{'after':after,'before':before}">
        <view :style="leftStyle">
            <slot name='left'></slot>
        </view>
        <view :style="rightStyle">
            <slot name='right'></slot>
        </view>
    </view>
</template>
 
<script>
    export default {
        props: {
            layout:{
                type: Number,
                default:50
            },
            // 容器顶部边框
            before: {
                type: Boolean,
                default: false
            },
            // 容器底部边框
            after: {
                type: Boolean,
                default: true
            }
        },
        data(){
            return {
                proportion:50
            }
        },
        computed: {
            leftStyle() {
                if(this.layout<=100 && this.layout>=0){
                    this.proportion=this.layout;
                }
                return {
                    float: 'left',
                    width: this.proportion===0?'0': this.proportion+'%'
                }
            },
            rightStyle() {
                return {
                    float: 'right',
                    width: (100-this.proportion)===0?'0': (100-this.proportion)+'%'
                }
            }
        },
        methods: {
        }
    }
</script>
 
<style>
    .uni-layout-row {
        display: flex;
        flex-direction: row;
        position: relative;
        line-height: 40px;
        height: 40px;
    }
    
    .uni-layout-row.before::before {
        position: absolute;
        right: 0;
        top: 0;
        left: 0;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(0.5);
        transform: scaleY(0.5);
        background-color: #c8c7cc;
        z-index: 99; /* 这里会被input覆盖1px给了一个置顶 */
    }
    
    .uni-layout-row.after::after {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(0.5);
        transform: scaleY(0.5);
        background-color: #c8c7cc;
    }
    
</style>