<template>
  <div class="swtich-Tab-wrapper">
    <div v-for="(item, index) in swtichText" @click="swtichClick(index)" :class="{active: swtichActive === index}">
      {{item}}
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      swtichText: {
        type: Array,
        default: ['公司地址', '收货地址']
      }
    },
    data() {
      return {
        swtichActive: 0
      }
    },
    methods: {
      swtichClick(index) {
        this.swtichActive = index
        this.$emit('swtichClick', index)
      }
    }
  }
</script>

<style scoped type="text/scss" lang="scss">
  .swtich-Tab-wrapper {
    margin-top: 24px;
    position: relative;
    height: 35px;
    padding-left: 30px;
    margin-bottom: 24px;
    &::after {
      position: absolute;
      width: 100%;
      height: 1px;
      background: #0d5ffe;
      bottom: 0px;
      left: 0px;
      content: ' ';
      z-index: 2;
    }
    div {
      color: #999;
      background: #fff;
      border: 1px solid #999;
      padding: 0 14px;
      border-bottom: 0px;
      display: inline-block;
      height: 35px;
      line-height: 35px;
      margin-right: 10px;
      cursor: pointer;
      font-size: 14px;
      &:hover {
        color: #409EFF;
        border: 1px solid #0d5ffe;
        border-bottom: 1px solid #fff;
      }
      &.active {
        color: #409EFF;
        border: 1px solid #0d5ffe;
        border-bottom: 1px solid #fff;
        position: relative;
        z-index: 3
      }
    }
  }
</style>
