王继章,米机王咏春拳,萧军简介
如下所示:
<template> <div> <table id="longzhoufeng" class="table table-striped table-bordered" width="100%" style="border: 0 solid #fff;margin-top: 10px;"> <thead class="thead-bottom-line"> <tr> <th class="sorting-title">名称1</th> <th class="sorting-title">名称2</th> <th class="sorting-title">名称3</th> <th class="sorting-title">名称4</th> </tr> </thead> <tbody> <tr @click="activehover(index)" class="list-table-hover" v-for="(item,index) in items" > <th class="sorting-title">{{item.text}}</th> <th class="sorting-title">{{item.text}}</th> <th class="sorting-title">{{item.text}}</th> <th class="sorting-title">{{item.text}}</th> </tr> </tbody> </table> </div> </template>
vue js代码
<script> export default { data:function() { return{ items: [ { text: '巴士' }, { text: '快车' }, { text: '专车' }, { text: '顺风车' }, { text: '出租车' }, { text: '代驾' } ], } }, methods:{ activehover:function(index){ var arrli=[]; var ali=$("table tbody tr") for(var i=0;i<ali.length;i++){ arrli.push(ali[i]) } for( var i=0; i<arrli.length; i++ ){ if(arrli[i] !=this){ $(arrli[i]).removeclass("active") } if(!$(arrli[i]).hasclass("active")){ $(arrli[index]).addclass("active") }else{ $(arrli[i]).removeclass("active") } } }, } } </script>
css代码
<style scoped> .abc{ background-color: #2aabd2; } table>thead.thead-bottom-line{ border-bottom: 1px solid #eeeeef; border-top: 1px solid #eeeeef; background-color: #fff; } table>thead>tr>th.sorting-title{ height: 35px; line-height: 35px; border: 0px solid #000000; font-weight: bold } table>tbody>tr.list-table-hover{ height: 30px; line-height: 30px; background-color: #fff !important; border-top: 0px solid #eeeeef; border-left: 0px solid #eeeeef; border-right: 0px solid #eeeeef; border-bottom: 1px solid #eeeeef; } table>tbody>tr:hover{ background-color: rgba(130, 219, 201, .5)!important; } table>tbody>tr.list-table-hover:hover{ height: 30px; line-height: 20px; background-color: rgba(130, 219, 201, .5)!important; border-top: 0px solid #eeeeef; border-left: 0px solid #eeeeef; border-right: 0px solid #eeeeef; border-bottom: 1px solid #eeeeef; } table>tbody>tr.list-table-hover.active{ background-color: rgba(130, 219, 201, .5)!important; } table>tbody>tr>td.sorting_content{ height: 30px; line-height: 20px; /*background-color: #fff;*/ border-top: 0px solid #eeeeef; border-left: 0px solid #eeeeef; border-right: 0px solid #eeeeef; border-bottom: 1px solid #eeeeef; } table>tbody>tr>td.sorting_content:last-child{ height: 30px; line-height: 30px; min-width: 120px; border-top: 0px solid #eeeeef; border-left: 0px solid #eeeeef; border-right: 0px solid #eeeeef; border-bottom: 1px solid #eeeeef; } </style>
知识拓展:vue实现点击选中,其他的不选中方法
如下所示:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>选中效果</title> <script src="../static/js/vue.min.js"></script> <style> ul li.active{ color: green; } </style> </head> <body> <div id="app"> <ul> <li v-for="items in navlist" :class="{active:items.isactive}" @click="activefun(items)"> <a> {{items.text}} </a> </li> </ul> </div> <script> new vue({ el: '#app', data: { navlist: [ {text: '首页', isactive: true}, {text: '简介', isactive: false}, {text: '活动', isactive: false}, {text: '联系', isactive: false} ] }, methods: { activefun: function(data){ this.navlist.foreach(function(obj){ obj.isactive = false; }); data.isactive = !data.isactive; } } }); </script> </body> </html>
以上这篇vuejs选中当前样式active的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
VUE+elementui组件在table-cell单元格中绘制微型echarts图
Vue通过getAction的finally来最大程度避免影响主数据呈现问题
vue 路由懒加载中给 Webpack Chunks 命名的方法
网友评论