slider
滑动选择器。
属性
支持通用属性
| 属性名 | 类型 | 默认值 | 说明 | 平台支持 |
|---|---|---|---|---|
| min | Number | 0 | 最小值 | all |
| max | Number | 100 | 最大值 | all |
| step | Number | 1 | 步长,取值必须大于 0,并且可被(max - min)整除 | all |
| disabled | Boolean | false | 是否禁用 | u?,w,a |
| value | Number | 0 | 当前取值 | all |
| activeColor | Color | #1aad19 | 已选择的颜色 | u?,w,a |
| backgroundColor | Color | #e9e9e9 | 背景条的颜色 | u?,w,a |
| show-value | Boolean | false | 是否显示当前 value | u?,w,a |
事件
支持通用事件
| 事件名 | 说明 | 平台支持 |
|---|---|---|
| onchange | <radio-group/>中的选中项发生变化时触发 change 事件,event.detail = {value: 选中项radio的value} |
all |
示例
<view class="section section_gap">
<text class="section__title">设置left/right icon</text>
<view class="body-view">
<slider onchange="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 onchange="slider2change" step="5"/>
</view>
</view>
<view class="section section_gap">
<text class="section__title">显示当前value</text>
<view class="body-view">
<slider onchange="slider3change" show-value/>
</view>
</view>
<view class="section section_gap">
<text class="section__title">设置最小/最大值</text>
<view class="body-view">
<slider onchange="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)