<!--
 * @Author: wally
 * @email: 18603454788@163.com
 * @Date: 2021-01-13 17:25:56
 * @LastEditors: wally
 * @LastEditTime: 2021-01-13 18:19:19
-->
<template>
  <div class="nav-box">
    <div
      :class="activeNum === index ? 'nav-item-active' : 'nav-item'"
      :key="index"
      @click="jump(item.url, index)"
      class="d-flex flex-column justify-center"
      v-for="(item, index) in list"
    >{{ item.title }}</div>
  </div>
</template>

<script>
export default {
  name: 'LeftNav',
  data() {
    return {
      str: '导航条',
      activeNum: 0,
      list: [
        {
          title: '智慧创新研究院',
          url: '/ServiceMarket/Institute',
        },
        {
          title: '科技创新服务',
          url: '/ServiceMarket/InnovativeService',
        },
        {
          title: '合作伙伴',
          url: '/ServiceMarket/Partner',
        },
      ],
    };
  },
  created() {
    if (this.$route.fullPath === '/ServiceMarket/InnovativeService') {
      this.activeNum = 1;
    } else if (this.$route.fullPath === '/ServiceMarket/Partner') {
      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>
