<template>
  <div class="tabs">
    <div class="tab" :class="value2 === item.value?'cur':''" v-for="(item,index) in list" @click="tabClick(index)" :key="index">
      {{item.label}}
    </div>
  </div>
</template>

<script>
export default {
  name: "Tabs",
  props: {
    list:{
      type: Array,
      default: () => []
    },
    value:{
      type: [String,Number],
      default: ''
    }
  },
  data() {
    return {
      value2: this.value,
    }
  },
  mounted() {
    this.value2 = this.value
  },
  methods: {
    tabClick(index) {
      this.value2 = this.list[index].value
      this.$emit('changeVal',this.value)
      this.$emit('changeLabel',this.list[index].label)
    }
  }
}
</script>

<style scoped lang="scss">
.tabs {
  display: flex;
  .tab {
    cursor: pointer;
    padding: 10px 11px;
    font-size: 14px;
    font-weight: 400;
    color: #FFFFFF;
    background: url("@/assets/images/manyidu/tab.png") repeat-x top left;
    margin-right: 4px;
    &.cur {
      background: url("@/assets/images/manyidu/tab_cur.png") repeat-x top left;
    }
  }
}
</style>