vue 弧形tab切换组件

csharp 复制代码
<template>
<div class="tab">
  <div class="tab-item" v-for="(item,index) in tabList" :key="index" :class="{'active':index == activeIndex}" @click="changeTab(index)">
    <div class="item">
      {{item.title}}
    </div>
  </div>
</div>
</template>

<script>
export default {
  name: 'tabIndex',
  props: {
    tabList: {
      type: Array,
      default: () => [{
          title: '已完成',
        },
        {
          title: '未完成',
        },
        {
          title: '已结束',
        },
      ]
    }
  },
  data() {
    return {
      activeIndex: 0,
    }
  },
  methods: {
    changeTab(index) {
      this.activeIndex = index;
      this.$emit('click', index);
    }
  },

}
</script>

<style lang="scss" scoped>
.tab {
  display: flex;
  justify-content: space-around;
  .tab-item {
    background-color: #eee;
    width: 150px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    margin: 0 10px;
    border-radius: 10px 10px 0 0;
    position: relative;
    transform: perspective(30px) rotateX(10deg);
    .item {
      transform: perspective(30px) rotateX(-10deg);
      margin-top: 5px;
    }
  }
  $w:30px;
  $w1:29px;
  $actColor:#0056f5;
  .tab-item::after,
  .tab-item::before {
    position: absolute;
    content: '';
    width: $w;
    height: $w;
    bottom: 0;
    background-color: #eee;
    border: none;
  }
  .tab-item::after {
    right: -$w1;
    background: radial-gradient(circle at 100% 0, transparent $w, #eee $w);
  }
  .tab-item::before {
    left: -$w;
    background: radial-gradient(circle at 0 0, transparent $w, #eee $w);
  }
  .active {
    z-index: 10;
    &::after {
      background: radial-gradient(circle at 100% 0, transparent $w, $actColor $w);
    }
    &::before {
      background: radial-gradient(circle at 0 0, transparent $w, $actColor $w);
    }
    background-color: $actColor;
    color: #fff;
  }
}
</style>
相关推荐
CDwenhuohuo9 小时前
微信小程序里用 setData() 修改数据并打印输出 的几种写法
javascript·微信小程序·小程序
前端一小卒10 小时前
生产环境Sourcemap策略:从苹果事故看前端构建安全架构设计
前端·javascript
im_AMBER11 小时前
React 18
前端·javascript·笔记·学习·react.js·前端框架
老前端的功夫11 小时前
Vue2中key的深度解析:Diff算法的性能优化之道
前端·javascript·vue.js·算法·性能优化
集成显卡11 小时前
AI取名大师 | PM2 部署 Bun.js 应用及配置 Let‘s Encrypt 免费 HTTPS 证书
开发语言·javascript·人工智能
han_11 小时前
前端高频面试题之Vue(高级篇)
前端·vue.js·面试
不说别的就是很菜12 小时前
【前端面试】CSS篇
前端·css·面试
脸大是真的好~12 小时前
黑马JAVAWeb -Vue工程化-API风格 - 组合式API
前端·javascript·vue.js
我命由我1234512 小时前
CesiumJS 案例 P35:添加图片图层(添加图片数据)
开发语言·前端·javascript·css·html·html5·js
你挚爱的强哥12 小时前
【sgMobileUploadTypeSelect】自定义组件:从底部弹出选择上传图片文件的方式【1、上传本地文件,2、拍摄上传】
前端·javascript·vue.js