国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

vue循環中點擊選中再點擊取消(單選)的實現

瀏覽:5日期:2022-11-25 09:01:17

沒有展開時

vue循環中點擊選中再點擊取消(單選)的實現

點擊展開之后

vue循環中點擊選中再點擊取消(單選)的實現

<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 @click='tocomment(index)'><i :class='{showcolor:currentTab==index}'></i>10</span> </div> </div> <div :class='{’showcomment’:currentTab==index}'> <div class='textarea_com'> <textarea placeholder='你來談談?' v-on:input='change' v-model='comment'></textarea> <button :class='{’showcolor’:showcombtn}'>發表</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 循環多個標簽,點擊標簽變色,再點擊取消,可以同時點擊多個

效果如下:

vue循環中點擊選中再點擊取消(單選)的實現

1.

<div class='relFacilityTitcon'> <i v-for='(item,index) in facilityList' :key='index' @click='changeSpan(index);' : >{{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循環中點擊選中再點擊取消(單選)的實現就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 龙陵县| 花垣县| 万山特区| 宜城市| 大方县| 四会市| 温州市| 常州市| 磐安县| 周口市| 阳泉市| 九江县| 伊川县| 荣昌县| 汶上县| 新干县| 孝义市| 桂东县| 行唐县| 保定市| 班戈县| 仁寿县| 忻城县| 广宁县| 礼泉县| 岳西县| 红安县| 临洮县| 花垣县| 策勒县| 丹凤县| 胶州市| 萍乡市| 礼泉县| 黎城县| 奎屯市| 城固县| 乌什县| 古浪县| 永善县| 清水河县|