最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vuejs選中當前樣式active的實例

 更新時間:2018年08月22日 15:48:18   作者:longzhoufeng  
今天小編就為大家分享一篇vuejs選中當前樣式active的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

如下所示:

<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: '順風(fēng)車' },
     { 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實現(xiàn)點擊選中,其他的不選中方法

如下所示:

<!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: '聯(lián)系', isActive: false}
   ]
  },
  methods: {
   activeFun: function(data){
    this.navList.forEach(function(obj){
     obj.isActive = false;
    });
    data.isActive = !data.isActive;
   }
  }
 });
</script>


</body>
</html>

以上這篇vuejs選中當前樣式active的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue.js在使用中的一些注意知識點

    Vue.js在使用中的一些注意知識點

    這篇文章主要給大家介紹了Vue.js在使用中的一些注意知識點,文中介紹的非常詳細,對大家學(xué)習(xí)或者使用Vue.js具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。
    2017-04-04
  • 詳解如何在vue中封裝axios請求并集中管理

    詳解如何在vue中封裝axios請求并集中管理

    這篇文章主要為大家詳細介紹了如何在vue中封裝axios請求并集中管理,w文中的示例代碼講解詳細,具有一定的參考價值,有需要的小伙伴可以了解下
    2023-10-10
  • vue如何關(guān)閉prettier警告warn

    vue如何關(guān)閉prettier警告warn

    這篇文章主要介紹了vue如何關(guān)閉prettier警告warn問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • 詳解基于webpack和vue.js搭建開發(fā)環(huán)境

    詳解基于webpack和vue.js搭建開發(fā)環(huán)境

    本篇文章主要介紹了詳解基于webpack和vue.js搭建開發(fā)環(huán)境 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • Vue組件通信$attrs、$listeners實現(xiàn)原理解析

    Vue組件通信$attrs、$listeners實現(xiàn)原理解析

    這篇文章主要介紹了Vue組件通信$attrs、$listeners實現(xiàn)原理解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-09-09
  • Vue檢測屏幕變化來改變不同的charts樣式實例

    Vue檢測屏幕變化來改變不同的charts樣式實例

    這篇文章主要介紹了Vue檢測屏幕變化來改變不同的charts樣式實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10
  • Vue3中事件總線mitt的使用方式

    Vue3中事件總線mitt的使用方式

    mitt又稱事務(wù)總線,是第三方插件,這篇文章主要為大家詳細介紹了Vue3中事件總線mitt的使用方式,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-03-03
  • 詳解vue3.0 的 Composition API 的一種使用方法

    詳解vue3.0 的 Composition API 的一種使用方法

    這篇文章主要介紹了vue3.0 的 Composition API 的一種使用方法,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-10-10
  • vue中如何獲取本地IP地址

    vue中如何獲取本地IP地址

    這篇文章主要介紹了vue中如何獲取本地IP地址,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue3 element plus中el-radio選中之后再次點擊取消選中問題

    vue3 element plus中el-radio選中之后再次點擊取消選中問題

    這篇文章主要介紹了vue3 element plus中el-radio選中之后再次點擊取消選中問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08

最新評論

津南区| 内黄县| 抚顺县| 陈巴尔虎旗| 宽城| 万源市| 沾化县| 集贤县| 县级市| 海淀区| 韶关市| 江西省| 巴塘县| 临漳县| 仙居县| 韶关市| 彝良县| 精河县| 定兴县| 大田县| 临邑县| 碌曲县| 昌邑市| 赤壁市| 墨玉县| 日喀则市| 灵丘县| 凌海市| 铁岭市| 乌兰察布市| 沭阳县| 嘉定区| 汾阳市| 桃园县| 石屏县| 泸州市| 通山县| 抚顺市| 新营市| 兴宁市| 临高县|