vue3 数据可视化大屏tab组件-异形按钮

vue3 数据可视化大屏 项目开发中,会需要一些tab切换组件,虽然已经有一些现成的组件了,这里整理的是vue3 数据可视化大屏tab组件-异形按钮

vue3 数据可视化大屏tab组件-异形按钮

vue3 数据可视化大屏tab组件-异形按钮,左上角缺角效果装饰。

vue3 数据可视化大屏tab组件-异形按钮

使用组件

/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年06月21日21:05:17
* @Desc: tab按钮
*/
<template>
  <div class="tabs">
    <tab v-model:active="active" :list="navList"></tab>
  </div>
</template>
<script>
import tab from './tab.vue'

export default {
  name: "tabs",
  components: {tab},
  data() {
    return {
      active: '0',
      navList: [{
        name: '告警详情',
        id: '0'
      }, {
        name: '统计分析',
        id: '1'
      }, {
        name: '历史查询',
        id: '1'
      }]
    }
  },
}
</script>
<style scoped lang="scss">
.tabs {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  width: calc(100% - 40px);
  margin: 10px auto;
}
</style>

tab按钮效果

根据当前选中的组件,进行id变换

/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年06月21日21:05:29
* @Desc: tab组件
*/
<template>
  <div class="tabs">
    <div class="tab cur"
         :class="{active:active==item.id}" @click="getactive(item.id)" v-for="(item,index) in list"
         :key="index">
      <span>{{ item.name }}</span>
      <div class="bg">
        <div class="bg1"></div>
        <div class="bg2"></div>
        <div class="bg3"></div>
      </div>
    </div>
  </div>
</template>
<script>

export default {
  name: "tabs",
  components: {},
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    },
    active: {
      type: [Number, String],
      default() {
        return 0;
      }
    },
  },
  data() {
    return {
      bgActive: ''
    }
  },
  watch: {},
  mounted() {
  },
  methods: {
    getactive(e) {
      this.$emit('update:active', e)
    },
  }
}
</script>
<style scoped lang="scss">
.tabs {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;

  .tab {
    min-width: 84px;
    height: 33px;
    opacity: 1;
    display: flex;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-right: 10px;
    position: relative;

    span {
      font-size: 14px;
      font-family: PingFang;
      font-weight: 500;
      color: rgba(214, 238, 255, 1);
      padding: 0 20px;
    }

    .bg {
      width: 100%;
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      height: 100%;
      z-index: -1;
      pointer-events: none;

      .bg1 {
        background: url("./assets/tabbg1.png");
        width: 9px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg2 {
        background: url("./assets/tabbg2.png");
        width: calc(100% - 9px - 2px);
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg3 {
        background: url("./assets/tabbg3.png");
        width: 2px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }
    }
  }

  .tab.active,.tab:hover {
    span {
      opacity: 1;
      color: rgba(214, 238, 255, 1);
    }

    .bg {
      .bg1 {
        background: url("./assets/tabActivebg1.png");
        width: 9px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg2 {
        background: url("./assets/tabActivebg2.png");
        width: calc(100% - 9px - 2px);
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg3 {
        background: url("./assets/tabActivebg3.png");
        width: 2px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }
    }
  }
}
</style>

路由模式

按钮点击后进行路由跳转,并高亮当前路由按钮

/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年06月21日21:05:29
* @Desc: tab路由写法
*/
<template>
  <div class="tabs">
    <router-link class="tab cur"
                 :to="item.url" v-for="(item,index) in list"
                 :key="index">
      <span>{{ item.name }}</span>
      <div class="bg">
        <div class="bg1"></div>
        <div class="bg2"></div>
        <div class="bg3"></div>
      </div>
    </router-link>
  </div>
</template>
<script>

export default {
  name: "tabs",
  components: {},
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    },
    active: {
      type: [Number, String],
      default() {
        return 0;
      }
    },
  },
  data() {
    return {
      bgActive: ''
    }
  },
  watch: {},
  mounted() {
  },
  methods: {
    getactive(e) {
      this.$emit('update:active', e)
    },
    handleMouseOver(e) {
      // 鼠标移上去事件的处理逻辑
      console.log("鼠标移上去了");
      this.bgActive = e
    },
    handleMouseOut() {
      // 鼠标移开事件的处理逻辑
      console.log("鼠标移开了");
      this.bgActive = null
    },
  }
}
</script>
<style scoped lang="scss">
.tabs {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;

  .tab {
    min-width: 84px;
    height: 33px;
    opacity: 1;
    display: flex;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-right: 50px;
    position: relative;

    span {
      font-size: 14px;
      font-family: PingFang;
      font-weight: 500;
      color: rgba(214, 238, 255, 1);
      padding: 0 20px;
    }

    .bg {
      width: 100%;
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      height: 100%;
      z-index: -1;
      pointer-events: none;

      .bg1 {
        background: url("./assets/tabbg1.png");
        width: 9px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg2 {
        background: url("./assets/tabbg2.png");
        width: calc(100% - 9px - 2px);
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg3 {
        background: url("./assets/tabbg3.png");
        width: 2px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }
    }
  }

  .tab.active, .tab:hover, .tab.router-link-exact-active {
    span {
      opacity: 1;
      color: rgba(214, 238, 255, 1);
    }

    .bg {

      .bg1 {
        background: url("./assets/tabActivebg1.png");
        width: 9px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg2 {
        background: url("./assets/tabActivebg2.png");
        width: calc(100% - 9px - 2px);
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }

      .bg3 {
        background: url("./assets/tabActivebg3.png");
        width: 2px;
        height: 100%;
        position: relative;
        background-size: 100% 100%;
      }
    }
  }
}

</style>

vue3 数据可视化大屏tab ui组件汇总整合

vue3 数据可视化大屏tab ui组件汇总整合

源文件下载

效果代码 vue3 vite js nodejs 14

相关文件下载地址
此资源需支付 ¥1 后下载
支付宝购买扫右侧红包码购买更优惠,如无法下载请联系微信:17331886870
喜欢
vue3 数据可视化大屏tab组件-异形按钮