tab切换做hover效果和点击效果


我用el-tab做完后,发现默认有个高亮的效果,但是hover触发后,另外一个也会高亮,同时两个高亮,然后修改

                     <div class="tabs">
                            <span :class="i.value==activeName?'tabHover':''"  
                           @mouseenter="onMouseenter(i.value)"  
                           @click="handleClick(i.value)" v-for="(i,key) in tabData" :key="key">{{i.label}}</span>
                      </div>
定义数据
   tabData:[
                {label:"国家政策",value:"first"},
                {label:"地方政策",value:"second"},
            ]
鼠标移入效果

 

        onMouseenter(value){
            this.activeName=value
          if(value=="first"){
              this.newData=this.countryData
          }else{
              this.newData=this.localData 
          }
        },
鼠标点击效果

 

 

handleClick(name){
            this.activeName=name
            console.log("name",name)
            if(name=="first"){
                let counLink=this.$router.resolve({path:"/hotpolicy", query: {name: "国家"}})
                window.open(counLink.href,"_blank")
            }else if(name=="second"){
                let landLink=this.$router.resolve({path:"/hotpolicy", query: {name: "地方"}})
                window.open(landLink.href,"_blank")
            }
        },
样式
 
.tabs{
                    span{
                        margin-right: 10px;
                        cursor: pointer;
                    }
                  .tabHover{
                    color: #0080ff;
                  }
                }

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM