Tab.vue 1.05 KB
<template>
  <div class="tab">
    <div
      :class="['tab-item',{ 'item-active': activeName == item.id }]"
      v-for="item in tabList"
      :key="item.id"
      @click="$emit('update:activeName',item.id)"
    >{{item.label}}</div>
  </div>
</template>

<script type='text/ecmascript-6'>
export default {
  props: {
    tabList: {
      type: Array,
      default: () => []
    },
    activeName: {
      type: String,
      default: ''
    }
  },
  name: '',
  data () {
    return {
    }
  },
  mounted () {
  },
  methods: {
  }
}
</script>

<style scoped lang='scss'>
.tab {
  width: fit-content;
  height: 38px;
  border-radius: 4px;
  background: #e8e8e8;
  margin: 0 20px 21px;
  border: 2px solid #e8e8e8;
  display: flex;
  align-items: center;
  .tab-item {
    padding: 0 24px;
    display: flex;
    height: 100%;
    align-items: center;
    font-size: 14px;
    color: #666666;
    cursor: pointer;
    user-select: none;
    transition: all .15s;
  }
  .item-active {
    background-color: #fff;
    color: #2A58AD;
    border-radius: 3px;
  }
}
</style>