/*! For license information please see 8611.43c9d310.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["8611"],{49166:function(n,t,s){"use strict";s.r(t);var a=s("80681");let e=["innerHTML"];t.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
The stepper component consists of an increase button, a decrease button and an input box, which are used to input and adjust numbers within a certain range.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Stepper } from 'vant';\n\nconst app = createApp();\napp.use(Stepper);\n
\n<van-stepper v-model="value" />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const value = ref(1);\n return { value };\n },\n};\n
\n<van-stepper v-model="value" step="2" />\n
\n<van-stepper v-model="value" min="5" max="8" />\n
\n<van-stepper v-model="value" integer />\n
\n<van-stepper v-model="value" disabled />\n
\n<van-stepper v-model="value" disable-input />\n
\n<van-stepper v-model="value" step="0.2" :decimal-length="1" />\n
\n<van-stepper v-model="value" input-width="40px" button-size="32px" />\n
\n<van-stepper v-model="value" :before-change="beforeChange" />\n
\nimport { ref } from 'vue';\nimport { closeToast, showLoadingToast } from 'vant';\n\nexport default {\n setup() {\n const value = ref(1);\n\n const beforeChange = (value) => {\n showLoadingToast({ forbidClick: true });\n\n return new Promise((resolve) => {\n setTimeout(() => {\n closeToast();\n // resolve 'true' or 'false'\n resolve(true);\n }, 500);\n });\n };\n\n return {\n value,\n beforeChange,\n };\n },\n};\n
\n<van-stepper v-model="value" theme="round" button-size="22" disable-input />\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model | \nCurrent value | \nnumber | string | \n- | \n
min | \nMin value | \nnumber | string | \n1 | \n
max | \nMax value | \nnumber | string | \n- | \n
auto-fixed | \nWhether to auto fix value that is out of range, set to false and value that is out of range won\u2019t be auto fixed | \nboolean | \ntrue | \n
default-value | \nDefault value, valid when v-model is empty | \nnumber | string | \n1 | \n
step | \nValue change step | \nnumber | string | \n1 | \n
name | \nStepper name, usually a unique string or number | \nnumber | string | \n- | \n
input-width | \nInput width | \nnumber | string | \n32px | \n
button-size | \nButton size | \nnumber | string | \n28px | \n
decimal-length | \nDecimal length | \nnumber | string | \n- | \n
theme | \nTheme, can be set to round | \nstring | \n- | \n
placeholder | \nInput placeholder | \nstring | \n- | \n
integer | \nWhether to allow only integers | \nboolean | \nfalse | \n
disabled | \nWhether to disable value change | \nboolean | \nfalse | \n
disable-plus | \nWhether to disable plus button | \nboolean | \nfalse | \n
disable-minus | \nWhether to disable minus button | \nboolean | \nfalse | \n
disable-input | \nWhether to disable input | \nboolean | \nfalse | \n
before-change | \nCallback function before changing, return false to prevent change, support return Promise | \n(value: number | string) => boolean | Promise<boolean> | \nfalse | \n
show-plus | \nWhether to show plus button | \nboolean | \ntrue | \n
show-minus | \nWhether to show minus button | \nboolean | \ntrue | \n
show-input | \nWhether to show input | \nboolean | \ntrue | \n
long-press | \nWhether to enable the long press gesture, when enabled you can long press the increase and decrease buttons | \nboolean | \ntrue | \n
allow-empty | \nWhether to allow the input value to be empty, set to true to allow an empty string to be passed in | \nboolean | \nfalse | \n
Event | \nDescription | \nArguments | \n
---|---|---|
change | \nEmitted when value changed | \nvalue: string, detail: { name: string } | \n
overlimit | \nEmitted when a disabled button is clicked | \n- | \n
plus | \nEmitted when the plus button is clicked | \n- | \n
minus | \nEmitted when the minus button is clicked | \n- | \n
focus | \nEmitted when the input is focused | \nevent: Event | \n
blur | \nEmitted when the input is blurred | \nevent: Event | \n
The component exports the following type definitions:
\nimport type { StepperTheme, StepperProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-stepper-background | \nvar(--van-active-color) | \n- | \n
--van-stepper-button-icon-color | \nvar(--van-text-color) | \n- | \n
--van-stepper-button-disabled-color | \nvar(--van-background) | \n- | \n
--van-stepper-button-disabled-icon-color | \nvar(--van-gray-5) | \n- | \n
--van-stepper-button-round-theme-color | \nvar(--van-primary-color) | \n- | \n
--van-stepper-input-width | \n32px | \n- | \n
--van-stepper-input-height | \n28px | \n- | \n
--van-stepper-input-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-stepper-input-line-height | \nnormal | \n- | \n
--van-stepper-input-text-color | \nvar(--van-text-color) | \n- | \n
--van-stepper-input-disabled-text-color | \nvar(--van-text-color-3) | \n- | \n
--van-stepper-input-disabled-background | \nvar(--van-active-color) | \n- | \n
--van-stepper-radius | \nvar(--van-radius-md) | \n- | \n