zoukankan      html  css  js  c++  java
  • taro3.x: checkbox使用问题

    准备数据:

    interface ISandState {
        value: string
        text: string
        checked: boolean
    }
    
    const INIT_SAND_STATE: ISandState[] = [
        {
            value: '1',
            text: '在售',
            checked: true
        },
        {
            value: '2',
            text: '待售',
            checked: true
        },
        {
            value: '3',
            text: '售完',
            checked: true
        }
    ]
    

      

    tsx:

    <View className="sand-state">
                            <CheckboxGroup className="sand-state-box">
                                {
                                    sandState.map((item: any, index: any) => (
                                        <Label className="check-label" for={index} key={index}>
                                            <Checkbox
                                                className="check-box"
                                                value={item.value}
                                                checked={item.checked}
                                            >
                                            </Checkbox>
                                            <Text className="check-text">{item.text}</Text>
                                        </Label>
                                    ))
                                }
                            </CheckboxGroup>
                            <View className="sand-state-btn">收起</View>
                        </View>

    样式

    .sand-state {
                display: flex;
                justify-content: center;
                align-items: center;
                position: absolute;
                right: 30px;
                bottom: 30px;
    
                &-box {
                    flex: auto;
                    height: 60px;
                    line-height: 60px;
                    font-size: $font-basic;
                    padding: 0 40px 0 20px;
                    margin-right: -30px;
                    border-radius: 30px;
                    background-color: rgba($color: $white, $alpha: .9);
                    transition: .3s;
    
                    &.hide {//添加隐藏样式时 transition动画执行
                        width: 0;
                        padding: 0;
                        overflow: hidden;
                    }
    
                    .check-label {
                        margin: 0 10px;
                        .check-box {
                            vertical-align: 2px;
                            .wx-checkbox-input {
                                width: 30px;
                                height: 30px;
                            }
                        }
                        .check-text {
                            color: $text-color;
                        }
                    }
                }
    
                &-btn {
                    width: 90px;
                    height: 90px;
                    line-height: 90px;
                    font-size: $font-basic;
                    border-radius: 50%;
                    text-align: center;
                    background-color: $white;
                    color: $title-color;
                }
            }

    改checkbox的默认样式

     <Checkbox
        className="check-box"
        value={item.value}
         checked={item.checked}
    >
    </Checkbox>
    check-box下微信内部样式:
    .check-box .wx-checkbox-input {}
    .check-box .wx-checkbox-input.wx-checkbox-input-checked{}选中样式
    .check-box .wx-checkbox-input.wx-checkbox-input-checked::before{}
    

    图例:

     

    
    
  • 相关阅读:
    CodeForces 670E Correct Bracket Sequence Editor
    CodeForces 670F Restore a Number
    HDU 5895 Mathematician QSC
    HDU 5880 Family View
    HDU 5886 Tower Defence
    CSS3.16
    CSS页面定制代码+动漫人物设计
    TSP变形(三进制状压)
    三进制状压(涂抹果酱)
    最小点覆盖(König定理)
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/13728312.html
Copyright © 2011-2022 走看看