Skip to content
On this page

Stepper 步进器

注:

  • 支持表单,具体可参考 Form
vue
<template>
  <ta-group title="基础用法">
    <ta-cell label="默认">
      <ta-stepper />
    </ta-cell>
    <ta-cell label="步长设置">
      <ta-stepper :step="2" />
    </ta-cell>
    <ta-cell label="限制输入范围">
      <ta-stepper :min="5" :max="10" />
    </ta-cell>
    <ta-cell label="限制输入整数">
      <ta-stepper :decimal-length="0" />
    </ta-cell>
    <ta-cell label="禁用状态">
      <ta-stepper :disabled="true" />
    </ta-cell>
    <ta-cell label="禁用输入框">
      <ta-stepper :disabled-input="true" />
    </ta-cell>
    <ta-cell label="固定小数位">
      <ta-stepper :decimal-length="1" :step="0.2" />
    </ta-cell>
  </ta-group>
  <ta-group title="事件监听">
    <ta-cell label="change">
      <ta-stepper @change="onChange" v-model="value" />
    </ta-cell>
    <ta-cell label="input/focus/blur/plus-click/minus-click">
      <ta-stepper
        @plus-click="onPlusClick"
        @minus-click="onMinusClick"
        @focus="onFocus"
        @blur="onBlur"
        @input="onInput"
      />
    </ta-cell>
  </ta-group>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { showToast } from '@/index'

export default defineComponent({
  name: 'ExpStepper',
  data() {
    return { value: '1' }
  },
  methods: {
    onChange(value: string) {
      console.log('change', value)
      showToast(`值改变为:${value}`)
    },
    onInput(value: string) {
      console.log('input', value)
      showToast(`当前值为:${value}`)
    },
    onPlusClick() {
      showToast('点击 + 按钮')
    },
    onMinusClick() {
      showToast('点击 - 按钮')
    },
    onFocus() {
      showToast('聚焦 focus')
    },
    onBlur() {
      showToast('失焦 blur')
    }
  }
})
</script>

Import

js
import { TaStepper } from 'tantalum-ui-mobile'

具体的引入方式可以参考引入组件

Props

属性类型默认值必填说明
v-modelnumber
namestring标识
minnumber0最小值
maxnumberInfinity最大值
disabledbooleanfalse是否禁用
disabled-plusbooleanfalse是否禁用增加按钮
disabled-minusbooleanfalse是否禁用减少按钮
disabled-inputbooleanfalse是否禁用输入框输入
show-valuebooleanfalse是否显示当前 value
decimal-lengthnumber格式化到小数点后固定位数,设置为 0 表示格式化到整数
stepnumber1步长,可以为小数

Events

事件描述回调函数参数
change当绑定值变化时触发value: number | string
input输入框输入时触发value: number | string
focus输入框聚焦时触发e: FocusEvent
blur输入框失焦时触发e: FocusEvent
plus-click点击增加按钮时触发
minus-click点击减少按钮时触发