codecamp

百度智能小程序 滑动选择器

slider 滑动选择器

解释:滑动选择器

属性说明

属性名 类型 默认值 必填 说明

min

Number

0

最小值

max

Number

100

最大值

step

Number

1

步长,取值必须大于 0,并且可被 (max - min) 整除

disabled

Boolean

false

是否禁用

value

Number

0

当前取值

backgroundColor

Color

#cccccc

背景条的颜色

block-size

Number

24

滑块的大小,取值范围为 12 - 28

block-color

Color

#ffffff

滑块的颜色

activeColor

Color

#3c76ff

已选择的颜色

show-value

Boolean

false

是否显示当前 value

bindchange

EventHandle

完成一次拖动后触发的事件,event.detail = {value: value}

bindchanging

EventHandle

拖动过程中触发的事件,event.detail = {value: value}

示例 

在开发者工具中打开


代码示例 1 - 默认样式

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">默认样式</view>
        <slider 
            class="slider" 
            min="0" 
            max="1500" 
            value="200" 
            step="30" 
            bind:change="sliderChange"
            bind:changing="sliderChanging"
            disabled="false">
        </slider>
    </view>
</view>
Page({
    sliderChange(e) {
        console.log('sliderChange', e.detail);
    },
    sliderChanging(e) {
        console.log('sliderChanging', e.detail);
    }
});

代码示例 2 - 显示当前取值

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>显示当前取值</view>
            <view>show-value</view>
        </view>
        <slider 
            class="slider" 
            min="0" 
            max="200" 
            value="30" 
            show-value 
            step="30" 
            bind:change="sliderChange"
            disabled="false">
        </slider>
    </view>
</view>

代码示例 3 - 自定义最大/最小值

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>自定义最大/最小值</view>
            <view>min="200" max="1500"</view>
        </view>
        <slider 
            class="slider" 
            min="200" 
            max="1500" 
            value="400"  
            show-value step="30"
            bind:change="sliderChange"
            disabled="false">
        </slider>
    </view>
</view>

代码示例 4 - 自定义步长

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>自定义步长</view>
            <view>step="30"</view>
        </view>
        <slider 
            class="slider" 
            min="0" 
            max="1500" 
            value="200" 
            step="30" 
            bind:change="sliderChange"
            disabled="false">
        </slider>
    </view>
</view>

代码示例 5 - 自定义样式

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">
            <view>自定义样式</view>
            <view>block-size="16"  block-color="#3388FF"</view>
        </view>
        <slider 
            class="slider"  
            min="0" 
            max="1500" 
            value="200" 
            step="30" 
            block-size="16"  
            block-color="#3388FF"
            activeColor="#3c76ff"
            backgroundColor="#cccccc"
            disabled="false">
        </slider>
    </view>
</view>


百度智能小程序 单项选择器组
百度智能小程序 开关选择器
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }