Skip to content

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>

属性

名称类型默认值说明可选值
sizeStringmini组件尺寸large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你)
typeString""组件类型info(信息), primary(正常), error(错误), warning(警告), success(成功)
disabledBooleanfalse组件是否禁用false, true
stopBooleanfalse是否阻止事件冒泡(Tui统一写法处理事件冒泡)false, true
hoverBooleantrue是否有点击效果false, true
pathString""点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。-
mainClassString""组件根节点的样式-
nativeClassString""组件根节点原生样式-
effectString"normal"组件显示主题normal(正常), dark(深色), light(浅色), plain(镂空)
minNumber1最小值
modelValueany``双向绑定的值
activeColorString``已选择的颜色
fontSizeString28rpx字体大小
decimalPlacesNumber1保留的小数位数
directionStringhorizontal组件绘制方式horizontal: 水平方向
vertical: 垂直方向
inactiveColorString``未选择的颜色
typeStringp组件类型
showValuePositionBooleantrue是否显示单位
maxNumber100最大值
blockSizeString50滑块的大小尺寸
showValueBooleanfalse是否显示值
trackSizeString5滑块轨道的尺寸
showModeStringbefore滑块数值的显示模式after: 在滑块后面显示值
before: 在滑块前面显示值

事件

名称返回参数说明
change(e:number[])值发生变化时触发