TopTab.vue 1.24 KB
<template>
  <div class="tab-box">
    <div class="flex">
      <div v-for="(item, index) in tabList" :key="index" class="tab-item" :class="tabActive == index ? 'tab-item-active' : ''" @click="changeTab(index)">{{ item }}</div>
    </div>
    <div>
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TopTab',
  props: {
    tabList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      tabActive: 0
    }
  },

  mounted() {},

  methods: {
    // tab切换
    changeTab(index) {
      this.tabActive = index
      this.$emit('tabChange', index)
    }
  }
}
</script>

<style lang="scss" scoped>
.tab-box {
  height: 4.44vh;
  display: flex;
  justify-content: space-between;
  padding: 0.2vh 0.2vw;
  box-sizing: border-box;
  border: 2px solid;
  border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
  .tab-item {
    height: 3.56vh;
    line-height: 3.56vh;
    font-weight: 400;
    font-size: 14px;
    color: #ffffffbf;
    padding: 0 1.11vw;
    cursor: pointer;
  }
  .tab-item-active {
    font-weight: 500;
    font-size: 14px;
    color: #ffffff;
    background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
  }
}
.flex {
  display: flex;
}
</style>