Five stars in WeChat applets

Source: Internet
Author: User
We often have comments on services or items. the general method is five stars, and the rating is quickly achieved through touch. We often have comments on services or items. the general method is five stars, and the rating is quickly achieved through touch.


Let's take a look at the implementation:

WXML code

   
   
  
   
Description
    
         
          
          
          
          
      
     
 

JS code

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

Here, the specific value of this score is controlled and determined by the variation of the flag value of a variable.
Bind an event function for each star to change the score to set the value change.

WCSS code

/* Star Style */. 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 ;*/}


For more articles related to five-star reviews in small programs, please follow the PHP Chinese website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.