小程序实现五星点评效果

先看一下效果图:

小程序实现五星点评效果

如上图所示,这里我们要添加三个五星点评。

我们这里之讲解一下,“描述相符”的点评

WXML代码

<!--星星评价--> <view> <view>描述相符</view> <view> <view bindtap="changeColor1"></view> <view bindtap="changeColor2"></view> <view bindtap="changeColor3"></view> <view bindtap="changeColor4"></view> <view bindtap="changeColor5"></view> </view> </view>

JS代码

Page({ data:{ flag:0 }, changeColor1:function(){ var that = this; that.setData( { flag: 1 }); }, changeColor2:function(){ var that = this; that.setData( { flag:2 }); }, changeColor3:function(){ var that = this; that.setData( { flag: 3 }); }, changeColor4:function(){ var that = this; that.setData( { flag:4 }); }, changeColor5:function(){ var that = this; that.setData( { flag: 5 }); },

WCSS代码

/*星星的样式*/ .stars{ background-image: url("http://m.dev.vd.cn/static/xcx/v1/goo/star(灰)@1.5x.png"); width: 43rpx; height: 43rpx; background-size: 43rpx 43rpx; margin-left: 40rpx; } .on{ background-image: url("http://m.dev.vd.cn/static/xcx/v1/goo/star@1.5x.png"); width: 43rpx; height: 43rpx; background-size: 43rpx 43rpx; /*margin-left: 10px;*/ }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b5484c57db5d8fc7ccb8aadad4e2d1f3.html