Home  >  Article  >  Web Front-end  >  How to use the slider component to dynamically modify label transparency in WeChat mini programs

How to use the slider component to dynamically modify label transparency in WeChat mini programs

亚连
亚连Original
2018-06-22 17:12:272143browse

This article mainly introduces the method of WeChat applet to dynamically modify the label transparency based on the slider component. The image transparency change function can be realized by dragging the slider component, involving WeChat applet event binding, base64 format image loading and slider For tips on using components, friends in need can refer to

. This article describes the method of dynamically modifying label transparency based on the slider component of the WeChat applet. Share it with everyone for your reference, the details are as follows:

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"/>

opacity here:{{ imgOpacity}}imgOpacity:1 in bound data is used to indicate image transparency. At the same time bindchange="changeImgOpacity"Bind event processing function changeImgOpacity is used to change the transparency of the image.

index.js

var pageData={}
pageData.data={
 imgOpacity:1
}
pageData[&#39;changeImgOpacity&#39;]=function(e){
//console.log(e)
 this.setData({
  imgOpacity:e.detail.value
 })
}
Page(pageData)

Here we use setData to set transparencyimgOpacity, readers can use console.log(e) Get the e.detail.value that affects imgOpacity changes in the console, as shown below:

The slider component is still used here , this component mainly has the following attributes:

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to create a child process using node.js (detailed tutorial)

How to implement singleton mode using ES6

How to deploy the Angular project to nginx

How to use v-model in vue to achieve parent-child component communication

The above is the detailed content of How to use the slider component to dynamically modify label transparency in WeChat mini programs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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