Slider (滑块)
canvas绘制,支持显示百分比或者显示值,支持多滑块,滑块数据取决于绑定value值数组的长度
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page title="slider 滑块升级版" main-class="p-30">
<t-card title='SliderPlus 滑块升级版' sub-title="canvas绘制丝滑不卡,支持显示百分比或者显示值,支持多滑块,滑块数据取决于绑定value值数组的长度"
main-class="mb-30"></t-card>
<t-section main-class="mb-30" title="显示值"></t-section>
<t-slider main-class="tdr tdb h-260 mb-30" direction="horizontal" :min="0" :max="500" type="p" blockSize="60"
:disabled="false" :showValue="true" trackSize="20" v-model="values" showMode="after" />
<t-section main-class="mb-30" title="显示百分比"></t-section>
<t-slider main-class="tdr tdb h-260 mb-30" direction="horizontal" type="p" blockSize="50" :disabled="false"
trackSize="5" :modelValue="[0]" />
<t-section main-class="mb-30" title="防止文本超出边界"></t-section>
<t-slider main-class="tdr tdb h-260 mb-30" :min="999999999" :max="99999999999" direction="horizontal" type="p"
:showValue="true" blockSize="50" :disabled="false" trackSize="5" :modelValue="[999999999, 99999999999]" />
<t-row main-class="mb-30">
<t-slider main-class="tdr tdb h-600 w-260 mr-30" :min="0" :max="500" :modelValue="[0, 105, 250]"
direction="vertical" type="e" showMode="after" blockSize="50" trackSize="10" />
<t-slider main-class="tdr tdb h-600 w-260" :min="0" :max="500" :modelValue="[0, 105, 250]"
direction="vertical" type="s" blockSize="50" trackSize="10" />
</t-row>
</t-page>
</template>
<script setup>
const values = ref([0, 105, 500])
</script>
属性
名称 | 类型 | 默认值 | 说明 | 可选值 |
---|---|---|---|---|
size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
disabled | Boolean | false | 组件是否禁用 | false, true |
stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
hover | Boolean | true | 是否有点击效果 | false, true |
path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
mainClass | String | "" | 组件根节点的样式 | - |
nativeClass | String | "" | 组件根节点原生样式 | - |
effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
min | Number | 1 | 最小值 | |
modelValue | any | `` | 双向绑定的值 | |
activeColor | String | `` | 已选择的颜色 | |
fontSize | String | 28rpx | 字体大小 | |
decimalPlaces | Number | 1 | 保留的小数位数 | |
direction | String | horizontal | 组件绘制方式 | horizontal : 水平方向vertical : 垂直方向 |
inactiveColor | String | `` | 未选择的颜色 | |
type | String | p | 组件类型 | |
showValuePosition | Boolean | true | 是否显示单位 | |
max | Number | 100 | 最大值 | |
blockSize | String | 50 | 滑块的大小尺寸 | |
showValue | Boolean | false | 是否显示值 | |
trackSize | String | 5 | 滑块轨道的尺寸 | |
showMode | String | before | 滑块数值的显示模式 | after : 在滑块后面显示值before : 在滑块前面显示值 |
事件
名称 | 返回参数 | 说明 |
---|---|---|
change | (e:number[]) | 值发生变化时触发 |