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>
相关推荐
初遇你时动了情27 分钟前
react使用react-quill 富文本插件、加入handlers富文本不显示解决办法
前端·javascript·react.js
海上彼尚33 分钟前
RawShaderMaterial 与 ShaderMaterial
前端·javascript
一直走下去-明1 小时前
next.js-学习2
开发语言·javascript·学习
小仙有礼了1 小时前
ArcGis for js 4.x实现测量,测距,高程的功能
javascript·算法·arcgis
野槐1 小时前
react路由总结
前端·javascript·react.js
剑走偏锋o.O1 小时前
Vue.js 学习笔记:TodoList 待办事项小案例
vue.js·笔记·学习
一念春风2 小时前
HTML+JS+CSS 鼠标上下移动页面(非滚动条)
javascript·css·html
qq_12498707532 小时前
SpringBoot+Vue+微信小程序的猫咖小程序平台(程序+论文+讲解+安装+调试+售后)
vue.js·微信小程序·小程序·毕业设计
凉风听雪2 小时前
CSS实现图片缺角效果
前端·css·html·css3
hhw1991123 小时前
JavaScript知识点1
开发语言·前端·javascript