<template>
  <nav>
    <ul class="app-tab-nav">
      <li
        v-for="(item, index) in list"
        :key="index"
        :class="{ 'is-active': index === activeIndex }"
        @click="tabChange(index)"
      >
        <div>{{ item }}</div>
      </li>
    </ul>
  </nav>
</template>

<script>
export default {
  props: { list: { type: Array, default: () => [] }, active: { type: String } },
  data() {
    return {
      activeIndex: 0
    }
  },
  mounted() {
    console.log(this.list)
  },
  methods: {
    tabChange(index) {
      this.activeIndex = index
      this.$emit('tabChange', index)
    }
  }
}
</script>

<style lang="scss">
.app-tab-nav {
  display: flex;
  overflow: scroll;
  &::-webkit-scrollbar{
    display: none;
  }
  li {
    margin-left: 0.3rem;
    font-size: 0.14rem;
    line-height: 0.38rem;
    color: #333;
    &.is-active {
      border-bottom: 0.02rem solid #aa1941;
    }
    div{
      white-space: nowrap;
      cursor: pointer;
    }
  }
}
</style>
