zoukankan      html  css  js  c++  java
  • vue点击tab跳转页面,给点击的tab添加样式,且解决刷新以后点击的tab样式消失问题

    <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{
        nav: [
          {title: 'senUs'},
          {title: 'senGermany'},
          {title: 'senFrance'},

          {title: 'senUk'}
        ]
      }
    },

    computed:{

        isSelect:function(){

          return this.$route.name;

        }

    },

    methods:{
      selectNav (title) {  
        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  
        }  
      }  
     },
    .nij{
        p{
            line-height:30px;
        }
    }
    .active{  
      color: #ffd100;  
    } 
  • 相关阅读:
    Redis宣言
    软件工程
    分布式编程
    编程泛型
    tcp/ip高效编程总结
    IP协议详解
    gevent程序员指南
    网站架构
    这些话,是乔布斯给世间留下的真正伟大礼物
    Flink/Spark 如何实现动态更新作业配置
  • 原文地址:https://www.cnblogs.com/rachelch/p/8320437.html
Copyright © 2011-2022 走看看