The WeChat applet uses the slider component to dynamically modify the label transparency.

Source: Internet
Author: User

Example of how a applet dynamically modifies the label transparency based on the slider component.

This article describes how to dynamically modify the label transparency of a Applet based on the slider component. We will share this with you for your reference. The details are as follows:

1. Effect display

2. Key code

Index. wxml

<view class="img" style="opacity:{{imgOpacity}}"></view><slider min="0" max="1" step="0.1" show-value value="1" bindchange="changeImgOpacity"/>

Hereopacity:{{imgOpacity}}Bind dataimgOpacity:1Used to indicate the image transparency. At the same timebindchange="changeImgOpacity"The changeImgOpacity function is used to change the image transparency.

Index. js

var pageData={}pageData.data={  imgOpacity:1}pageData['changeImgOpacity']=function(e){  this.setData({    imgOpacity:e.detail.value  })}Page(pageData)

Used heresetDataSets the transparency imgOpacity.console.log(e)Obtain information that affects imgOpacity changes on the console.e.detail.valueSuch:

The slider component is used here, which has the following attributes:

3. Source CodeClick hereDownload from this site.

I hope this article will help you develop small programs.

Related Article

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.