Skip to content
# t-stepper

Stepper 步进器

t-stepper 组件介绍 ​

t-stepper 用于在指定数值范围内进行加减操作,支持最小值、最大值、步长配置,提供按钮样式自定义和长按快速增减功能。适用于商品数量选择、时间设置等场景。

t-stepper 平台兼容 ​

HarmonyH5AndroidiOS小程序UTS
✅✅✅✅✅✅

t-stepper 基础用法 ​

基础用法参考 demo/stepper/stepper.uvue,通过 v-model 双向绑定数值。

vue
<template>
	<view>
		<tui-theme-switch></tui-theme-switch>
		<t-card class="mlrt-15"
				title="Stepper 步进器"
				sub-title="步进器组件是一个用于在指定数值范围内进行加减操作的UI元素,支持多种配置,如最小值、最大值、步长、按钮样式等。使用场景包括在需要精确控制数值增减的场景,如设置时间、金额等。"></t-card>

		<introduction title="基础功能-类型-尺寸">
			<t-stepper class="mb-15"
					   v-model="vala"
					   :min="3"
					   :max="99"
					   type="primary"
					   size="large"></t-stepper>

			<t-stepper class="mb-15"
					   button-class='r-100!'
					   :input-class="[`bgn! w-25! ttc-`]"
					   v-model="vala"
					   :min="3"
					   :max="99"
					   type="warning"
					   size="medium"></t-stepper>

			<t-stepper class="mb-15"
					   v-model="vala"
					   :min="3"
					   :max="99"
					   type="success"
					   effect="light"
					   size="small"></t-stepper>

			<t-stepper class="mb-15"
					   v-model="vala"
					   buttonmain-class='r-100'
					   :min="3"
					   :max="99"
					   type="error"
					   size="mini"></t-stepper>
		</introduction>

		<introduction title="设置步长">
			<t-stepper :min="3"
					   :max="99"
					   class='w-125'
					   v-model="valaa1"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="宽度设置">
			<t-stepper class='w-225!'
					   :min="1"
					   :max="10"
					   v-model="valaa2"
					   type="success"></t-stepper>
		</introduction>

		<introduction title="禁用编辑">
			<t-stepper class='w-125'
					   :disabledInput="true"
					   :min="3"
					   :max="99"
					   v-model="valaa4"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="只能减少不能增加">
			<t-stepper :disablePlus="true"
					   :min="3"
					   :max="99"
					   v-model="valaa5"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="只能增加不能减少">
			<t-stepper :disableMinus="true"
					   :min="3"
					   :max="99"
					   v-model="valaa6"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="全部禁用">
			<t-stepper class='w-125'
					   :disabled="true"
					   :min="3"
					   :max="99"
					   v-model="valaa7"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="长按加减时间间隔">
			<t-stepper class='w-125'
					   :plusInterval="10"
					   :min="3"
					   :max="99"
					   v-model="valaa8"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>

		<introduction title="禁用长按加减">
			<t-stepper class='w-125'
					   :longPress="false"
					   :min="3"
					   :max="99"
					   v-model="valaa9"
					   :step="0.01"
					   type="primary"></t-stepper>
		</introduction>
	</view>
</template>

<script setup>
	import { ref } from 'vue'

	const val = ref(30)
	const vala = ref(1)
	const valaa1 = ref(1)
	const valaa2 = ref(1)
	const valaa3 = ref(1)
	const valaa4 = ref(6)
	const valaa5 = ref(6)
	const valaa6 = ref(6)
	const valaa7 = ref(6)
	const valaa8 = ref(6)
	const valaa9 = ref(6)
</script>

t-stepper Props ​

属性名说明类型默认值
path点击组件后跳转的页面路径;为空时仅响应事件string''
hover是否启用点击效果booleantrue
type组件主题类型,可选 info、primary、error、warning、successstring'primary'
disabled是否禁用整个组件booleanfalse
effect组件显示主题,可选 normal、dark、light、plainstring'normal'
size组件尺寸,可选 large、medium、small、ministring'medium'
modelValue当前数值number0
min最小值number0
max最大值number100
step步长,每次增减的值number1
buttonClass按钮的样式类string''
buttonLeftClass左侧按钮的样式类string''
buttonRightClass右侧按钮的样式类string''
iconMinusClass减少图标样式类string''
iconPlusClass增加图标样式类string''
inputClass输入框样式类string''
inputTextClass输入框文本样式类string''
iconMinus减少按钮图标名称string'minus'
iconPlus增加按钮图标名称string'plus'
showMinus是否显示减少按钮booleantrue
showPlus是否显示增加按钮booleantrue
disabledInput是否禁用输入框编辑booleanfalse
disableMinus是否禁用减少按钮booleanfalse
disablePlus是否禁用增加按钮booleanfalse
cursorSpacing指定光标与键盘的距离,避免键盘遮挡输入框(单位 px)number100
plusInterval长按加减的时间间隔(毫秒)number100
longPress是否允许长按进行快速加减booleantrue

t-stepper Events ​

事件名说明回调参数
update:modelValue值更新时触发number
change数值改变时触发number
click点击时触发-
touchstart触摸开始时触发-
touchend触摸结束时触发-
touchmove触摸移动时触发-
touchcancel触摸取消时触发-
transitionend动画结束时触发-
initFinished组件初始化完成时触发-

外部类 ​

类名说明
button-class按钮样式类
button-left-class左侧按钮样式类
button-right-class右侧按钮样式类
icon-minus-class减少图标样式类
icon-plus-class增加图标样式类
input-class输入框样式类
input-text-class输入框文本样式类