<template>
  <div class="nav-box d-flex">
    <div
      :class="activeNum === index ? 'nav-box-active' : ''"
      :key="index"
      @click="jump(item.url)"
      v-for="(item, index) in list"
    >{{ item.title }}</div>
  </div>
</template>

<script>
export default {
  name: 'HNav',
  data() {
    return {
      activeNum: 0,
      list: [
        {
          title: '众创空间',
          url: '/IncubationPlatform/MakerSpace',
        },
        {
          title: '公共实验室',
          url: '/IncubationPlatform/PublicLaboratory',
        },
        {
          title: '中试基地',
          url: '/IncubationPlatform/PilotBase',
        },
        {
          title: '创业导师',
          url: '/IncubationPlatform/Tutor',
        },
        {
          title: '合作伙伴',
          url: '/IncubationPlatform/Partner',
        },
        {
          title: '创业服务',
          url: '/IncubationPlatform/Services',
        },
        {
          title: '产品展示',
          url: '/IncubationPlatform/Products',
        },
      ],
    };
  },
  created() {
    console.log();
    if (this.$route.fullPath === '/IncubationPlatform/PublicLaboratory') {
      this.activeNum = 1;
    } else if (this.$route.fullPath === '/IncubationPlatform/PilotBase') {
      this.activeNum = 2;
    } else if (this.$route.fullPath === '/IncubationPlatform/Tutor') {
      this.activeNum = 3;
    } else if (this.$route.fullPath === '/IncubationPlatform/Partner') {
      this.activeNum = 4;
    } else if (this.$route.fullPath === '/IncubationPlatform/Services') {
      this.activeNum = 5;
    } else if (this.$route.fullPath === '/IncubationPlatform/Products') {
      this.activeNum = 6;
    } else {
      this.activeNum = 0;
    }
  },
  methods: {
    jump(url) {
      if (this.$route.fullPath === url) {
        // this.$message.success('已在当前界面');
      } else {
        this.$router.push(url);
      }
    },
  },
};
</script>

<style lang="stylus" scoped></style>
