WeChat Open Platform

Mini Programs Documentation

slider

Slide selector

Attribute name Type Default value Description
min Number 0 Minimum value
max Number 100 Maximum value
step Number 1 Step, value must be greater than 0 and be able to be divided exactly (max - min)
disabled Boolean false Whether disabled
value Number 0 Current value
color Color #e9e9e9 Background bar color (please use backgroundColor)
selected-color Color #1aad19 Selected color (please use activeColor)
activeColor Color #1aad19 Selected color
backgroundColor Color #e9e9e9 Background bar color
show-value Boolean false Whether to show current value
bindchange EventHandle An event triggered after completing a drag, event.detail = {value: value}

Sample code:

<view class="section section_gap">
  <text class="section__title">Set left/right icon</text>
  <view class="body-view">
    <slider bindchange="slider1change" left-icon="cancel" right-icon="success_no_circle"/>
  </view>
</view>

<view class="section section_gap">
  <text class="section__title">Set step</text>
  <view class="body-view">
    <slider bindchange="slider2change" step="5"/>
  </view>
</view>

<view class="section section_gap">
  <text class="section__title">Show current value</text>
  <view class="body-view">
    <slider bindchange="slider3change" show-value/>
  </view>
</view>

<view class="section section_gap">
  <text class="section__title">Set minimum/maximum value</text>
  <view class="body-view">
    <slider bindchange="slider4change" min="50" max="200" show-value/>
  </view>
</view>
var pageData = {}
for (var i = 1; i < 5; i++) {
  (function (index) {
    pageData['slider' + index + 'change'] = function(e) {
      console.log (if 'slider' + 'index' + 'change event occurs, the value brought is', e.detail.value)
    }
  })(i)
}
Page(pageData)

slider