菜单 点击选中 一个按钮跳转四个路由

4个页面同一个菜单 (菜单是子组件 )

实现点击跳转,并选中对应的 菜单

有什么疑问欢迎留言 ,感谢大家

 

源代码:

<template>

  <div class="navbox mt20 mr30" ref="nav">

    <a href="JavaScript:void(0)" class="flex row-center" v-for="(item,i) in editNav" :key="i" @click="clickNav(i)" :class="{cur:i==current}">

      <div>{{item.navIcon}}</div>

      <span>{{item.navName}}</span>

    </a>

  </div>

</template>

<script>

export default {

  name: 'EditNav',

  components: {

    

  },

  data(){

    return {

      current:null,

      editNav:[

        {navName:'技术百科',navIcon:'icon'},

        {navName:'国家政策',navIcon:'icon'},

        {navName:'行业之声',navIcon:'icon'},

        {navName:'突出问题',navIcon:'icon'},

      ]

    }

  },

  methods:{

    clickNav(index){

      if(index ==0){

        const {href} = this.$router.resolve({

          path: '/SpecialDetails/edit/EditTechnology',

          query: {

            eventId:this.eventId,

            eventName:this.eventName,

            current:index

          }

        });

        window.open(href,'_blank');

      }

      if(index ==1){

        const {href} = this.$router.resolve({

          path: '/SpecialDetails/edit/EditNationalPolicy',

          query: {

              eventId:this.eventId,

              eventName:this.eventName,

              current:index

          }

        });

        window.open(href, '_blank');

      }

      if(index ==2){

        const {href} = this.$router.resolve({

          path: '/SpecialDetails/edit/EditIndustry',

          query: {

              eventId:this.eventId,

              eventName:this.eventName,

              current:index

          }

        });

        window.open(href, '_blank');

      }

      if(index ==3){

        const {href} = this.$router.resolve({

          path: '/SpecialDetails/edit/EditProblem',

          query: {

            eventId:this.eventId,

            eventName:this.eventName,

            current:index

          }

        });

        window.open(href,'_blank');

      }

    },

  },

  created () {

    this.eventId = this.$route.query.eventId;

    this.eventName = this.$route.query.eventName;

    this.current = this.$route.query.current;

  },

}

</script>

<style scoped lang="less">

@cur-color:#1890FF;

@black-color:#000000;

.navbox{

  width:86px;

  font-size:14px;

  position: fixed;

  top: 120px;

  a{

    width:100%;

    height:86px;

    color:fade(@black-color,85%);

    background-color:fade(@black-color,3%);

    margin-bottom:2px;

    &.cur{

      color:@cur-color;

      background-color: fade(@cur-color,5%);

    }

    &:hover{

      color:@cur-color;

      background-color: fade(@cur-color,5%);

    }

  }

}

</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值