阅读(2666) (12)

slider

2020-02-11 17:54:43 更新
基础库 1.0.0 开始支持本组件。

滑动选择器。


属性说明

属性名类型默认值说明最低版本
minnumber0最小值1.0.0
maxnumber100最大值1.0.0
stepnumber1步长,取值必须大于 0,并且可被(max-min)整除1.0.0
disabledbooleanfalse是否禁用1.0.0
valuenumber0当前取值1.0.0
colorstring#e9e9e9背景条的颜色(请使用 background-color)1.0.0
selected-colorstring#1aad19已选择的颜色(请使用 active-color)1.0.0
active-colorstring#1aad19已选择的颜色1.0.0
background-colorstring#e9e9e9背景条的颜色1.0.0
block-sizebumber28滑块的大小,取值范围为 12 - 281.0.0
block-colorstring#ffffff滑块的颜色1.0.0
show-valuebooleanfalse是否显示当前 value1.0.0
bindchangeeventhandle完成一次拖动后触发的事件,event.detail = {value: value}1.0.0
bindchangingeventhandle拖动过程中触发的事件,event.detail = {value: value}1.0.0


效果示例


代码示例

<view class="page-section page-section-gap">
  <view class="page-section-title">设置step</view>
  <view class="body-view">
    <slider value="60" bindchange="slider2change" step="5" />
  </view>
</view>

<view class="page-section page-section-gap">
  <view class="page-section-title">显示当前value</view>
  <view class="body-view">
    <slider value="50" bindchange="slider3change" show-value />
  </view>
</view>

<view class="page-section page-section-gap">
  <view class="page-section-title">设置最小/最大值</view>
  <view class="body-view">
    <slider
      value="100"
      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);