wxml
<!--pages/index1/index1.wxml-->
<view class="box">
<image
wx:for="{{ [0,1,2,3,4] }}"
src="{{ activeIndex > index ? starFull : star }}"
bindtap="change"
data-index="{{ index + 1 }}"
></image>
</view>
js
Page({
data:{
star:"../../static/star.png",
starFull:"../../static/starFull.png",
activeIndex:0,
},
change(e){
let index = e.currentTarget.dataset.index;
this.setData({
activeIndex:index
})
}
})
wxss
/* pages/index1/index1.wxss */
.box{
width: 100%;
height:30px;
border: 1px solid #f00;
}
.box image{
width: 50px;
height: 30px;
}