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

<script>
export default {
  name: 'LeftNav',
  data() {
    return {
      str: '创新挑战导航条',
      activeNum: 0,
      list: [
        {
          title: '需求征集',
          url: '/Challenge/Solicitation',
        },
        {
          title: '项目发布',
          url: '/Challenge/Release',
        },
        {
          title: '结果公示',
          url: '/Challenge/Notice',
        },
      ],
    };
  },
  created() {
    if (this.$route.fullPath === '/Challenge/Release') {
      this.activeNum = 1;
    } else if (this.$route.fullPath === '/Challenge/Notice') {
      this.activeNum = 2;
    } else {
      this.activeNum = 0;
    }
  },
  methods: {
    jump(url, index) {
      if (this.$route.fullPath === url) {
        this.$message.success('已在当前界面');
      } else {
        this.$router.push(url);
        this.activeNum = index;
      }
    },
  },
};
</script>

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