微信小程序 滑动选择器 slider 组件

完整微信小程序(Java后端) 技术贴目录清单页面(必看)

滑动选择器。

属性 类型 默认值 必填 说明 最低版本
min number 0 最小值 1.0.0
max number 100 最大值 1.0.0
step number 1 步长,取值必须大于 0,并且可被(max - min)整除 1.0.0
disabled boolean false 是否禁用 1.0.0
value number 0 当前取值 1.0.0
color color #e9e9e9 背景条的颜色(请使用 backgroundColor) 1.0.0
selected-color color #1aad19 已选择的颜色(请使用 activeColor) 1.0.0
activeColor color #1aad19 已选择的颜色 1.0.0
backgroundColor color #e9e9e9 背景条的颜色 1.0.0
block-size number 28 滑块的大小,取值范围为 12 - 28 1.9.0
block-color color #ffffff 滑块的颜色 1.9.0
show-value boolean false 是否显示当前 value 1.0.0
bindchange eventhandle 完成一次拖动后触发的事件,event.detail = {value} 1.0.0
bindchanging eventhandle 拖动过程中触发的事件,event.detail = {value} 1.7.0

示例代码

在开发者工具中预览效果

index.wxml

<view class="page">
    <view class="page__hd">
        <text class="page__title">slidertext>
        <text class="page__desc">滑块text>
    view>
    <view class="page__bd">
        <view class="section section_gap">
            <text class="section__title">设置left/right icontext>
            <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">设置steptext>
            <view class="body-view">
                <slider bindchange="slider2change"  step="50"/>
            view>
        view>


        <view class="section section_gap">
            <text class="section__title">显示当前valuetext>
            <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>
    view>
view>

index.js

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)

运行效果:

微信小程序 滑动选择器 slider 组件_第1张图片

微信搜一搜【java1234】关注这个放荡不羁的程序员,关注后回复【资料】有我准备的一线大厂笔试面试资料以及简历模板。

你可能感兴趣的:(java,微信小程序,java)