码迷,mamicode.com
首页 > 其他好文 > 详细

vue点击tab跳转页面,给点击的tab添加样式,且解决刷新以后点击的tab样式消失问题

时间:2018-01-20 13:56:42      阅读:1909      评论:0      收藏:0      [点我收藏+]

标签:bre   div   sector   blog   ase   style   height   break   click   

<ul class="nij">  
    <li v-for="item in nav" @click="selectNav(item.title)">  
        <p :class="isSelect === item.title ? ‘active‘ : ‘‘">{{item.title}}</p>  
    </li>  
</ul>  
     

data:function(){
  return{
    isSelect: ‘senUs‘,
    nav: [
      {title: ‘senUs‘},
      {title: ‘senGermany‘},
      {title: ‘senFrance‘},

      {title: ‘senUk‘}
    ]
  }
},

methods:{
  selectNav (title) {  
     var that=this;
     this.$nextTick(function(){
        that.isSelect = that.$route.name  
     })
    switch (title) {  
       case ‘senUs‘: this.$router.push(‘/sentiSectors/senUs‘)  
       break  
       case ‘senGermany‘: this.$router.push(‘/sentiSectors/senGermany‘)  
       break  
       case ‘senFrance‘: this.$router.push(‘/sentiSectors/senFrance‘)  
       break  
       case ‘senUk‘: this.$router.push(‘/sentiSectors/senUk‘)  
       break  
    }  
  }  
 },
 mounted(){
    this.isSelect = this.$route.name;
 },
.nij{
    p{
        line-height:30px;
    }
}
.active{  
  color: #ffd100;  
} 

 

vue点击tab跳转页面,给点击的tab添加样式,且解决刷新以后点击的tab样式消失问题

标签:bre   div   sector   blog   ase   style   height   break   click   

原文地址:https://www.cnblogs.com/rachelch/p/8320437.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!