效果(点击改变背景色):
wxml:
1 2 |
<view class="{{_id==1?'click-style':'normal-style'}}" data-id="1" bindtap="Choosen">是</view> <view class="{{_id==2?'click-style':'normal-style'}}" data-id="2" bindtap="Choosen" >否</view> |
js:
1 2 3 4 5 |
Choosen: function (e) { this.setData({ _id: e.target.dataset.id }) }, |
wxss:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
.normal-style { width:49%; padding-top:20rpx; padding-bottom:20rpx; display:inline-block; text-align:center; background:#fff; border:1px solid #f1f1f1; } .click-style{ width:49%; padding-top:20rpx; padding-bottom:20rpx; display:inline-block; text-align:center; background:#1F4495; border:1px solid #f1f1f1; color:#fff; } |
文章评论 暂无评论
暂无评论