vue3中 自定义tabs

效果图

template 使用 

// 使用
<div class="tabs">
      <div class="tab" :class="{ active: active.tab1 === index }"  v-for="(item, index) in tabsList1" :key="index" @click="changeTab(1, index)"> {{ item.label }}
  </div>

script

<script setup lang="ts">
const tabsList = [

    { label: '日' },
    { label: '月' },
];

const tabsList1 = [

    { label: '日' },
    { label: '月' },
];

const active = ref({
    tab1: 0,
    tab2: 0,
});

<script>

scss样式

 // tabs样式
        .tabs {
            margin-top: vw(10);

            display: flex;

            // gap: 20px;

            .tab {
                text-align: center;
                width: 70px;
                height: 25px;
                background-color: #07ffd5;
                padding: 3px 10px;
                position: relative;
                transform: scale(1);
                transform-origin: left bottom;
                border-radius: 5px;
                transition: background-color .3s, color .3s, transform .3s;

                &:before,
                &:after {
                    content: "";
                    position: absolute;
                    display: block;
                    background-color: #FFFFFF;
                    width: 15px;
                    height: 100%;
                    top: 0;
                    z-index: -1;
                    transition: background-color .3s;
                }

                &:before {
                    left: 0;
                    transform: skewX(20deg) translateX(-50%);
                }

                &:after {
                    right: 0;
                    transform: skewX(20deg) translateX(50%);
                }

                &.active {
                    background-color: #007AFF;
                    color: #ffff;
                    transform: scale(1.11);
                    z-index: 9;

                    &:before,
                    &:after {
                        background-color: #007AFF;
                    }

                    &:before {
                        border-top-left-radius: 5px;
                        border-bottom-left-radius: 5px;
                    }

                    &:after {
                        border-top-right-radius: 5px;
                        border-bottom-right-radius: 5px;
                    }

                }

                &:first-child:before,
                &:last-child:after {
                    display: none;
                }

                &:first-child {
                    padding-left: 20px;
                }

                &:last-child {
                    padding-right: 20px;
                }
            }
        }

暂存

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值