uniapp实现弧形tab选项卡

1、效果图

2、完整代码

<template>
  <view class="wrap">
    <view class="tab_box">
      <view class="tab_item" :class="tabIndex == index ? `active active${index}` : ''" v-for="(item, index) in tabList"
        :key="index" @click="changeTab(index)">
        {{ item.name }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      tabIndex: 1,
      tabList: [{
        name: '测试1',
        id: 1
      }, {
        name: '测试2',
        id: 2
      }, {
        name: '测试3',
        id: 3
      }],
    };
  },
  methods: {
    changeTab(index) {
      this.tabIndex = index

    },
  }
}
</script>

<style lang="scss" scoped>
.wrap {
  padding: 50rpx 30rpx;

  .tab_box {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 87rpx;
    border-radius: 24rpx 24rpx 0rpx 0rpx;
    background: #F7F0E8;
    color: #78532A;
    font-size: 30rpx;

    .tab_item.active {
      height: 110rpx;
      line-height: 110rpx;
      background: #fff;
      font-weight: bold;

      &::after {
        position: absolute;
        content: "";
        width: 60rpx;
        height: 60rpx;
        right: -60rpx;
        bottom: 0;

      }

      &::before {
        position: absolute;
        content: "";
        width: 60rpx;
        height: 60rpx;
        bottom: 0;
        left: -60rpx;
      }
    }

    .active0 {
      border-radius: 24rpx 24rpx 0 0;

      &::after {
        background: radial-gradient(circle at 60rpx 0, transparent 60rpx, #fff 60rpx);
      }
    }

    .active1 {
      border-radius: 24rpx 24rpx 0 0;

      &::after {

        background: radial-gradient(circle at 60rpx 0, transparent 60rpx, #fff 60rpx);
      }

      &::before {
        background: radial-gradient(circle at 0 0, transparent 60rpx, #fff 60rpx);
      }
    }

    .active2 {
      border-radius: 24rpx 0 0 0;

      &::before {
        background: radial-gradient(circle at 0 0, transparent 60rpx, #fff 60rpx);
      }
    }

    .tab_item {
      position: relative;
      width: 33.33%;
      text-align: center;
      line-height: 87rpx;
    }
  }
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值