欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue循環(huán)中點擊選中再點擊取消(單選)的實現(xiàn)

 更新時間:2020年09月10日 08:34:23   作者:Archer_yy  
這篇文章主要介紹了vue循環(huán)中點擊選中再點擊取消(單選)的實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

沒有展開時

點擊展開之后

<div class="flashread_item_box_time">
      <span class="moment_time">9分鐘前</span>
      <div class="flashread_item_box_zan">
       <span class="flashread_item_box_item"><i class="iconfont icon-changyongtubiao-mianxing-"></i>10</span>
       <span class="flashread_item_box_item" @click="tocomment(index)"><i class="iconfont icon-pinglun" :class="{showcolor:currentTab==index}"></i>10</span>
      </div>
     </div>
     <div class="comment_textareabox" :class="{'showcomment':currentTab==index}">
      <div class="textarea_com">
       <textarea placeholder="你來談?wù)劊? class="comment_textarea" v-on:input="change" v-model="comment"></textarea>
       <button class="btn_comment" :class="{'showcolor':showcombtn}">發(fā)表</button>
      </div>
     </div>
data(){
  return{
   currentTab:-1,
   flashreadlists:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],
   showcombtn:false,
   comment:''
  }
 },
 methods:{
  change(){
   if(this.comment.length>=1){
    this.showcombtn=true
   }else{
    this.showcombtn=false
   }
  },
  tocomment(index){
   if(index!=this.currentTab){
    this.currentTab = index;

   }else{
    this.currentTab = -1;

   }
  }
 }

補充知識:vue 循環(huán)多個標簽,點擊標簽變色,再點擊取消,可以同時點擊多個

效果如下:

1.

<div class="relFacilityTitcon"> 
      <i v-for="(item,index) in facilityList" :key="index" @click="changeSpan(index);" :class="{'bgcolor':spanIndex.indexOf(index)>-1}" >{{item}}</i>
</div>

2.

.padding .relWarp .relFacility .relFacilityTitcon {
 
    /* border: 1px solid red; */
    /* line-height: 20px; */
    padding: 0 .24rem;
    font-size :10px;
  }
 
  .padding .relWarp .relFacility .relFacilityTitcon i {
    
    /* height:20px; */
    display: inline-block;
    /* margin: 0 5px; */
    height: 20px;
    line-height: 20px;
    padding: 0 .16rem;
    /* width: auto; */
    font-size: 10px;
    color: #97979f;
    border-radius: 5px;
    border: 1px solid #97979f;
    margin-right: 10px;
    margin-top: 10px;
    font-style: normal;
 
    /* padding:1px 7px; */
    /* display: inline-block; */
  }
  .padding .relWarp .relFacility .relFacilityTitcon .bgcolor {
    border: 1px solid orange;
    color: orange;
  }
 
  .padding .relWarp .relFacility .relFacilityTitcon i:last-child {
    margin-right: 0;
  }

3.

 methods: {
      
      changeSpan(index){
        let arrIndex = this.spanIndex.indexOf(index);
        // console.log(arrIndex);
        
        if(arrIndex>-1){
          this.spanIndex.splice(arrIndex,1);
        }else{
          this.spanIndex.push(index);
        }
      },

以上這篇vue循環(huán)中點擊選中再點擊取消(單選)的實現(xiàn)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue-vuex中使用commit提交mutation來修改state的方法詳解

    vue-vuex中使用commit提交mutation來修改state的方法詳解

    今天小編就為大家分享一篇vue-vuex中使用commit提交mutation來修改state的方法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 手寫Vue2.0 數(shù)據(jù)劫持的示例

    手寫Vue2.0 數(shù)據(jù)劫持的示例

    這篇文章主要介紹了手寫Vue2.0 數(shù)據(jù)劫持的示例,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-03-03
  • vue+element-plus上傳圖片及回顯問題及數(shù)量限制

    vue+element-plus上傳圖片及回顯問題及數(shù)量限制

    本文主要介紹了vue+element-plus上傳圖片及回顯問題及數(shù)量限制,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • Vue3中watch監(jiān)聽的五種情況詳解

    Vue3中watch監(jiān)聽的五種情況詳解

    watch函數(shù)用于偵聽某個值的變化,當(dāng)該值發(fā)生改變后,觸發(fā)對應(yīng)的處理邏輯,本文將給大家介紹了Vue3中watch監(jiān)聽的五種情況,文中通過代碼示例講解的非常詳細,具有一定的參考價值,需要的朋友可以參考下
    2024-03-03
  • 詳解vue 中使用 AJAX獲取數(shù)據(jù)的方法

    詳解vue 中使用 AJAX獲取數(shù)據(jù)的方法

    本篇文章主要介紹了詳解vue 中使用 AJAX獲取數(shù)據(jù)的方法,在VUE開發(fā)時,數(shù)據(jù)可以使用jquery和vue-resource來獲取數(shù)據(jù),有興趣的可以了解一下。
    2017-01-01
  • vue3+ts+Vuex中使用websocket協(xié)議方式

    vue3+ts+Vuex中使用websocket協(xié)議方式

    這篇文章主要介紹了vue3+ts+Vuex中使用websocket協(xié)議方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • vue項目中使用骨架屏的方法

    vue項目中使用骨架屏的方法

    在頁面加載數(shù)據(jù)之前,有一段空白時間,要么用loading加載,要么就用骨架屏,本文主要介紹了vue項目中使用骨架屏的方法,感興趣的可以了解一下
    2021-05-05
  • vue-router 源碼之實現(xiàn)一個簡單的 vue-router

    vue-router 源碼之實現(xiàn)一個簡單的 vue-router

    這篇文章主要介紹了vue-router 源碼之實現(xiàn)一個簡單的 vue-router,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • 基于Vue中點擊組件外關(guān)閉組件的實現(xiàn)方法

    基于Vue中點擊組件外關(guān)閉組件的實現(xiàn)方法

    下面小編就為大家分享一篇基于Vue中點擊組件外關(guān)閉組件的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • Element-ui?Dialog對話框基本使用

    Element-ui?Dialog對話框基本使用

    這篇文章主要為大家介紹了Element-ui?Dialog對話框基本使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-06-06

最新評論