Example of WeChat Mini Program to achieve five-star rating

黄舟
Release: 2017-09-13 09:11:28
Original
2418 people have browsed it

This article mainly introduces relevant information about implementation examples of WeChat Mini Program five-star rating. Here are implementation examples to help you implement the modified function. Friends in need can refer to

WeChat Mini Program Five-Star Rating

Five-star rating effect:


<view>
  <view class="zan-font-16 my-ib" bindtap="myStarChoose">
    <block wx:for="{{starMap}}">
      <text wx:if="{{star>=index+1}}" style="padding-right: .5em" class="zan-c-red" data-star="{{index+1}}">★</text>
      <text wx:if="{{star<index+1}}" style="padding-right: .5em" class="zan-c-gray-dark" data-star="{{index+1}}">☆</text>
    </block>
  </view>
  <!--★-->
  <text class="zan-c-gray-dark">{{starMap[star-1]}}</text>
</view>
Copy after login

Here are zan-font-16,zan-c-red,zan-c- gray-dark is the style of ZanUI-WeApp.

My-ib here just sets the display to inline-block.


Page({
  data: {
    star: 0,
    starMap: [
      &#39;非常差&#39;,
      &#39;差&#39;,
      &#39;一般&#39;,
      &#39;好&#39;,
      &#39;非常好&#39;,
    ],
  },
  myStarChoose(e) {
    let star = parseInt(e.target.dataset.star) || 0;
    this.setData({
      star: star,
    });
  }
});
Copy after login

The effect is as shown:

The above is the detailed content of Example of WeChat Mini Program to achieve five-star rating. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template