想要實現(xiàn)的效果:
1、點擊數(shù)字時背景為紅色,字體為白色
2、點擊1或2時,對應(yīng)下面的灰點消失,再次點擊其他數(shù)字時灰點顯示
wxml:
<block wx:for="{{weekDay}}" wx:key="item.index"> <view data-key="{{index}}" bindtap='select_d' class="day_list {{d_state==index?'red_day':''}}"> <text>{{item.day_n}}</text> <text class='{{item.dian_class}} {{item.state==0?"dian_none":"dian_block"}}'></text> </view> </block>
wxss:
.dian_none{ display: none!important; } .dian_block{ display: block!important; } .red_day{ background-color: #e33c3c; color: #ffffff; } .dian_d{ width: 9rpx; height: 9rpx; background-color: #d8d8d8; border-radius: 50%; display: block; }
js:
data: { date_week:["日","一","二","三","四","五","六"], weekDay:[ { day_n:"26", dian_class:"" }, { day_n: "27", dian_class: "" },{ day_n: "28", dian_class: "" }, { day_n: "29", dian_class: "" }, { day_n: "30", dian_class: "" }, { day_n: "1", dian_class: "dian_d", state:1 }, { day_n: "2", dian_class: "dian_d", state:1 } ], d_state:"0", }, select_d:function(e){ var array = this.data.weekDay; var index=e.currentTarget.dataset.key; if (array[index].dian_class =="dian_d"){ for (var i = 0; i < array.length; i++) { if (array[i].dian_class == "dian_d") { array[i].state = 1; } } array[index].state = 0; } else if (array[index].dian_class ==""){ for (var i = 0; i < array.length; i++){ if(array[i].dian_class=="dian_d"){ array[i].state = 1; } } } this.setData({ d_state:e.currentTarget.dataset.key, weekDay:this.data.weekDay }); }
免責(zé)聲明:本站所有文章和圖片均來自用戶分享和網(wǎng)絡(luò)收集,文章和圖片版權(quán)歸原作者及原出處所有,僅供學(xué)習(xí)與參考,請勿用于商業(yè)用途,如果損害了您的權(quán)利,請聯(lián)系網(wǎng)站客服處理。
工作日 8:30-12:00 14:30-18:00 周六及部分節(jié)假日提供值班服務(wù)
工作日 8:30-12:00 14:30-18:30