微信小程序星级评分

版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013982652/article/details/80336488

wxml文件

<view class='star_container'>
    <image class='star_icon' bindtap='starClick' id='1' src="{{curStarIndex<1?'../../images/star_gray.png':'../../images/star_light.png'}}"></image>
    <image class='star_icon' bindtap='starClick' id='2' src="{{curStarIndex<2?'../../images/star_gray.png':'../../images/star_light.png'}}"></image>
    <image class='star_icon' bindtap='starClick' id='3' src="{{curStarIndex<3?'../../images/star_gray.png':'../../images/star_light.png'}}"></image>
    <image class='star_icon' bindtap='starClick' id='4' src="{{curStarIndex<4?'../../images/star_gray.png':'../../images/star_light.png'}}"></image>
    <image class='star_icon' bindtap='starClick' id='5' src="{{curStarIndex<5?'../../images/star_gray.png':'../../images/star_light.png'}}"></image>
  </view>

js文件

starClick: function (e) {
    var index = parseInt(e.currentTarget.id);
    this.setData({
      curStarIndex: index,
    });
  }

效果如图所示


阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页