vue3 数据可视化大屏tab菱形背景效果

vue3 数据可视化大屏项目开发中,会需要一些tab切换组件,虽然已经有一些现成的组件了,这里整理的是tab的菱形背景效果。

vue 数据可视化大屏tab菱形背景效果

使用实例

使用组件

/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年05月21日
* @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'
      }]
    }
  },
}
</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>

组件代码

/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年05月21日
* @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">
      <img :src="item.icon" alt="">
      <span>{{ item.name }}</span>
    </div>
  </div>
</template>
<script>
export default {
  name: "tabs",
  components: {},
  props: {
    list: {
      type: Array,
      default() {
        return [];
      }
    },
    active: {
      type: [Number, String],
      default() {
        return 0;
      }
    },
  },
  data() {
    return {}
  },
  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 {
    width: 270px;
    height: 35px;
    background: url("./assets/tabbg.png") center center no-repeat;
    background-size: 100% 100%;
    opacity: 1;
    display: flex;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;

    span {
      font-size: 24px;
      font-family: YouSheBiaoTiHei;
      font-weight: 400;
      color: #FFFFFF;
    }
  }

  .tab.active {
    background: url("./assets/tabActivebg.png") center center no-repeat;
    background-size: 100% 100%;

    span {
      color: #FFFFFF;
    }
  }
}
</style>


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

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

喜欢