vue循環(huán)中點(diǎn)擊選中再點(diǎn)擊取消(單選)的實(shí)現(xiàn)
沒(méi)有展開(kāi)時(shí)

點(diǎn)擊展開(kāi)之后

<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="你來(lái)談?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;
}
}
}
補(bǔ)充知識(shí):vue 循環(huán)多個(gè)標(biāo)簽,點(diǎn)擊標(biāo)簽變色,再點(diǎn)擊取消,可以同時(shí)點(diǎn)擊多個(gè)
效果如下:

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)中點(diǎn)擊選中再點(diǎn)擊取消(單選)的實(shí)現(xiàn)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- vue中的循環(huán)對(duì)象屬性和屬性值用法
- Vue循環(huán)中多個(gè)input綁定指定v-model實(shí)例
- 解決vue-router路由攔截造成死循環(huán)問(wèn)題
- 解決vue中的無(wú)限循環(huán)問(wèn)題
- Vue 實(shí)現(xiàn)v-for循環(huán)的時(shí)候更改 class的樣式名稱(chēng)
- vue中v-for循環(huán)選中點(diǎn)擊的元素并對(duì)該元素添加樣式操作
- vue實(shí)現(xiàn)循環(huán)滾動(dòng)列表
- vue中 v-for循環(huán)的用法詳解
- Vue如何循環(huán)提取對(duì)象數(shù)組中的值
相關(guān)文章
vue-vuex中使用commit提交mutation來(lái)修改state的方法詳解
今天小編就為大家分享一篇vue-vuex中使用commit提交mutation來(lái)修改state的方法詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
手寫(xiě)Vue2.0 數(shù)據(jù)劫持的示例
這篇文章主要介紹了手寫(xiě)Vue2.0 數(shù)據(jù)劫持的示例,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下2021-03-03
vue+element-plus上傳圖片及回顯問(wèn)題及數(shù)量限制
本文主要介紹了vue+element-plus上傳圖片及回顯問(wèn)題及數(shù)量限制,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04
Vue3中watch監(jiān)聽(tīng)的五種情況詳解
watch函數(shù)用于偵聽(tīng)某個(gè)值的變化,當(dāng)該值發(fā)生改變后,觸發(fā)對(duì)應(yīng)的處理邏輯,本文將給大家介紹了Vue3中watch監(jiān)聽(tīng)的五種情況,文中通過(guò)代碼示例講解的非常詳細(xì),具有一定的參考價(jià)值,需要的朋友可以參考下2024-03-03
詳解vue 中使用 AJAX獲取數(shù)據(jù)的方法
本篇文章主要介紹了詳解vue 中使用 AJAX獲取數(shù)據(jù)的方法,在VUE開(kāi)發(fā)時(shí),數(shù)據(jù)可以使用jquery和vue-resource來(lái)獲取數(shù)據(jù),有興趣的可以了解一下。2017-01-01
vue3+ts+Vuex中使用websocket協(xié)議方式
這篇文章主要介紹了vue3+ts+Vuex中使用websocket協(xié)議方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
vue-router 源碼之實(shí)現(xiàn)一個(gè)簡(jiǎn)單的 vue-router
這篇文章主要介紹了vue-router 源碼之實(shí)現(xiàn)一個(gè)簡(jiǎn)單的 vue-router,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-07
基于Vue中點(diǎn)擊組件外關(guān)閉組件的實(shí)現(xiàn)方法
下面小編就為大家分享一篇基于Vue中點(diǎn)擊組件外關(guān)閉組件的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-03-03

