1.1.4 • Published 3 years ago

chan-stepper v1.1.4

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Stepper 步进器

介绍

  • 步进器由增加按钮、减少按钮和输入框组成,用于在一定范围内输入、调整数字。
  • 此组件解决了大部分开源UI框架提供的Stepper组件存在的痛点,如无法等待网络请求返回结果后再执行加减操作以及点击时没有进行防抖处理。
  • 基于Vue2.x,适用于电商项目。

安装

npm i chan-stepper --save

引入

// 全局引入
import Vue from 'vue';
import chan from 'chan-stepper';

Vue.use(chan);
// 全局按需引入
import Vue from 'vue';
import { Stepper } from 'chan-stepper';

Vue.use(Stepper);
// 在组件里引入
import { Stepper } from 'chan-stepper';

export default {
    name: 'App',
    components: {
        Stepper
    }
}

使用

<Stepper :qty.sync="qty" />
<Stepper v-for="item in shopList" :key="item.id" :qty.sync="item.qty" :item="item" :is-ajax="true" @change="cartChange" @blur="cartBlur" />

Props

参数说明类型默认值
qty当前输入的值Number | String1
step步长,每次点击时改变的值Number | String1
min最小值Number | String1
max最大值Number | StringInfinity
disabled是否禁用步进器Booleanfalse
disable-input是否禁用输入框Booleanfalse
is-ajaxajax网络请求后才进行加减操作Booleanfalse
item当is-ajax为true时,需要传当前属性值Object{}

Events

事件名说明回调参数
change当绑定值变化时触发的事件,当is-ajax为true时才生效item: {}, qty: number
blur输入框失焦时触发,当is-ajax为true时才生效item: {}, qty: number

注意

qty参数一定要添加sync修饰符,change和blur方法生效is-ajax属性必须为true。

<Stepper :qty.sync="qty" step="1" max="5" :is-ajax="true" @change="stepperChange" />
1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago