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>
相关推荐
踩着两条虫7 分钟前
VTJ.PRO 新手入门:从环境搭建到 AI 生成首个 Vue3 应用
前端·javascript·数据库·vue.js·人工智能·低代码
他是龙55117 分钟前
63:JS 加密断点调试与逆向实战
开发语言·javascript·状态模式
2601_9491942625 分钟前
TypeScript 与后端开发Node.js
javascript·typescript·node.js
前端那点事31 分钟前
Vue3 defineModel 完全不破坏单向数据流!底层原理+实战解析
vue.js
hmh1234536 分钟前
录音与音频可视化
前端·javascript
阿丰资源1 小时前
Java项目基于SpringBoot+Vue前后端分离在线商城系统(附源码)
java·vue.js·spring boot
江-月*夜1 小时前
vue3 wordcloud2.js词云使用
开发语言·javascript·vue.js
吴声子夜歌2 小时前
Vue3——Vuex状态管理
前端·vue.js·vue·es6
qq_12084093712 小时前
Three.js 工程向:Frustum Culling 与场景分块优化实战
前端·javascript