May 18, 2021 WeChat Mini Program Development Document
Slide the selector.
The property name | Type | The default | Description | The lowest version |
---|---|---|---|---|
min | Number | 0 | The minimum value | |
max | Number | 100 | The maximum value | |
step | Number | 1 | Step, the value must be greater than 0, and can be divided by (max - min). | |
disabled | Boolean | false | Whether to disable | |
value | Number | 0 | The current value | |
color | Color | #e9e9e9 | Color of the background bar (use backgroundColor) | |
selected-color | Color | #1aad19 | Color selected (use activeColor) | |
activeColor | Color | #1aad19 | The color selected | |
backgroundColor | Color | #e9e9e9 | The color of the background bar | |
show-value | Boolean | false | Whether the current value is displayed | |
bindchange | EventHandle | Events triggered after completing a drag, event.detail . | ||
bindchanging | EventHandle | Events triggered during drag, event.detail . | 1.7.0 |
Example code:
<view class="section section_gap">
<text class="section__title">设置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">设置step</text>
<view class="body-view">
<slider bindchange="slider2change" step="5"/>
</view>
</view>
<view class="section section_gap">
<text class="section__title">显示当前value</text>
<view class="body-view">
<slider bindchange="slider3change" show-value/>
</view>
</view>
<view class="section section_gap">
<text class="section__title">设置最小/最大值</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('slider' + 'index' + '发生 change 事件,携带值为', e.detail.value)
}
})(i);
}
Page(pageData)