Home  >  Article  >  Web Front-end  >  How to use slider to set data values ​​in WeChat applet

How to use slider to set data values ​​in WeChat applet

亚连
亚连Original
2018-06-21 17:41:214446browse

This article mainly introduces the WeChat applet's use of slider to set data values ​​and switch component functions. It analyzes the functions and usage of slider components and switch components in the form of examples. It also comes with source code for readers to download and refer to. Friends in need You can refer to the following

The example of this article describes the WeChat applet using slider to set data values ​​and switch component functions. Share it with everyone for your reference, as follows:

Key code

① index.wxml

<view>微信小程序组件:滑动选择器slider</view>
<slider bindchange="sliderBindchange" min="{{min}}" max="{{max}}" show-value/>
<view>最小值:{{min}}</view>
<view>最大值:{{max}}</view>
<view>当前值:{{text}}</view>
<view>---------------------------------</view>
<view>微信小程序组件:开关组件switch</view>
<switch checked type="switch" bindchange="switchBindchange"/>
<view>开关组件当前状态:{{switchState}}</view>

② index.js

Page({
 data:{
 // text:"这是一个页面"
 min:&#39;20&#39;,
 max:&#39;150&#39;,
 text:&#39;&#39;,
 switchState:&#39;开&#39;
 },
 sliderBindchange:function(e){
 this.setData({
  text:e.detail.value
 })
 },
 switchBindchange:function(e){
 if(e.detail.value){
  this.setData({
  switchState:&#39;开&#39;
  })
 }else{
  this.setData({
  switchState:&#39;关&#39;
  })
 }
 }
})

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

Related articles:

Use angular to write Message components

How to implement component communication in vue-cli

What should we pay attention to when optimizing Vue projects?

Developed in a modular way in vuejs

How to implement the array update function in VUE

How to use vue-cli to implement multi-page applications

The above is the detailed content of How to use slider to set data values ​​in WeChat applet. 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