<template>
  <div class="tabs">
    <div
      class="tab"
      :class="value2 === item.value ? 'cur' : ''"
      v-for="(item, index) in list"
      @click="tabClick(index)"
      :key="item.value"
    >
      {{ 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.value2);
      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: #96b1ce;
    min-width: 120px;
    background: url("@/assets/images/manyidu/tab.png") repeat-x top left;
    margin-right: 4px;
    text-align: center;
    &.cur {
      color: #ffffff;
      background: url("@/assets/images/manyidu/tab_cur.png") repeat-x top left;
    }
  }
}
</style>
