2020-10-06 17:19:19 +08:00
..
2020-08-16 15:29:57 +08:00
2020-10-02 21:41:01 +08:00
2020-09-05 07:17:49 +08:00
2020-09-28 11:46:26 +08:00

Stepper

Install

import { createApp } from 'vue';
import { Stepper } from 'vant';

const app = createApp();
app.use(Stepper);

Usage

Basic Usage

<van-stepper v-model="value" />
export default {
  data() {
    return {
      value: 1,
    };
  },
};

Step

<van-stepper v-model="value" step="2" />

Range

<van-stepper v-model="value" min="5" max="8" />

Integer

<van-stepper v-model="value" integer />

Disabled

<van-stepper v-model="value" disabled />

Disable Input

<van-stepper v-model="value" disable-input />

Decimal Length

<van-stepper v-model="value" step="0.2" :decimal-length="1" />

Custom Size

<van-stepper v-model="value" input-width="40px" button-size="32px" />

Async Change

<van-stepper :model-value="value" async-change @change="onChange" />
import { Toast } from 'vant';

export default {
  data() {
    return {
      value: 1,
    };
  },
  methods: {
    onChange(value) {
      Toast.loading({ forbidClick: true });

      setTimeout(() => {
        Toast.clear();
        this.value = value;
      }, 500);
    },
  },
};

Round Theme

<van-stepper v-model="value" theme="round" button-size="22" disable-input />

API

Props

Attribute Description Type Default
v-model Current value number | string -
min Min value number | string 1
max Max value number | string -
default-value Default value, valid when v-model is empty number | string 1
step Value change step number | string 1
name Stepper name number | string -
input-width Input width number | string 32px
button-size Button size number | string 28px
decimal-length Decimal length number | string -
theme v2.8.2 Theme, can be set to round string -
placeholder v2.8.6 Input placeholder string -
integer Whether to allow only integers boolean false
disabled Whether to disable value change boolean false
disable-plus Whether to disable plus button boolean false
disable-minus Whether to disable minus button boolean false
disable-input Whether to disable input boolean false
async-change Whether to enable async change boolean false
show-plus Whether to show plus button boolean true
show-minus Whether to show minus button boolean true
long-press v2.4.3 Whether to allow long press boolean true
allow-empty v2.9.1 Whether to allow the input to be empty boolean false

Events

Event Description Arguments
change Triggered when value change value: string, detail: { name: string }
overlimit Triggered when click disabled button -
plus Triggered when click plus button -
minus Triggered when click minus button -
focus Triggered when input focused event: Event
blur Triggered when input blured event: Event