一、微信小程序点击对应点击高亮
js代码
Page({data: {list: [1, 2, 3, 4, 5],active: 0},itemClickOne(e){var num=e.currentTarget.dataset.value;this.setData({active:num});},
})
wxml代码
<view class="list"><view class="item {{item==active?'active':''}}" wx:for="{{list}}"bind:tap="itemClickOne"data-value="{{item}}">{{item}}</view>
</view>
css代码
.list {border: 1px solid red;padding: 50px;text-align: center;
}.list .item {display: inline-block;width: 30px;height: 30px;background-color: blue;color: white;text-align: center;line-height: 30px;margin-right: 20px;
}
.list .item.active{background-color: red;
}
二、微信小程序实现打分功能效果
js代码 如上
wxml代码
<view class="list"><view class="item {{item<=active?'active':''}}" wx:for="{{list}}"bind:tap="itemClickOne"data-value="{{item}}">{{item}}</view>
</view>
css如上
更多: