zoukankan      html  css  js  c++  java
  • 手动实现一个公共vue组件

    实现了一个iphone上常见的siwtchbutton组件按钮,废话少说 直接看代码

    <template lang="html">
        <div class="button_switch" :class="{change_to_open: open}">
            <div class="circel_button" :class="{trans_to_right: open}" @click="changeType"></div>
        </div>
    </template>
    <script type="text/ecmascript-6">
        export default{
            name: 'switchbutton',
            props: ['open'],
            methods: {
                changeType() {
                    console.log(this.newMsgRemind);
                    console.log(this.open);
                    let code = this.open ? 1 : 0;
                    this.$emit('changeType', code);
                    // this.$store.commit(types.SET_CURRENT_CHANNEL_SESSION_NEW_MSG_REMIND, code);
                    // console.log(this.open);
                    // this.$api.ModifyNewMsgRemindConfig(this.$store.getters.currentChannelId, code);
                }
            }
        };
    </script>
    <style rel="stylesheet/scss" lang="scss" scoped>
        .button_switch {
            background-color: #fff;
            display: flex;
            justify-content: center;
            border-radius: 100px;
            border: 2px solid #E5E5E5;
             40px;
            height: 28px;
            position: relative;
            /*top: -5px;*/
            box-sizing: border-box;
            .circel_button{
                transition: all .3s;
                position: absolute;
                z-index: 1;
                top: 2px;
                left:1px;
                 20px;
                height: 20px;
                background: #FFFFFF;
                box-shadow: 0 0 4px 0 rgba(0,0,0,0.20);
                border-radius: 50%;
                cursor: pointer;
            }
            .trans_to_right{
                transform: translateX(13px);
            }
        }
        .change_to_open{
            background: #4DD865;
        }
    </style>
    

      

  • 相关阅读:
    Luogu P1169 [ZJOI2007]棋盘制作 及悬线法浅谈
    P4338 [ZJOI2018]历史 P3703 [SDOI2017]树点涂色 题解
    多省联考2020游记
    min_25筛基础
    斯特林数、贝尔数与伯努利数基础
    后缀数组笔记
    分治FFT学习笔记
    多项式运算表
    基本积分公式表
    THUWC2019游记
  • 原文地址:https://www.cnblogs.com/WhiteHorseIsNotHorse/p/7133343.html
Copyright © 2011-2022 走看看