Home > Article > Web Front-end > How to use slider to set data values in WeChat applet
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:'20', max:'150', text:'', switchState:'开' }, sliderBindchange:function(e){ this.setData({ text:e.detail.value }) }, switchBindchange:function(e){ if(e.detail.value){ this.setData({ switchState:'开' }) }else{ this.setData({ switchState:'关' }) } } })
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!