Stepper计步器

    引入

    在app.json或index.json中引入组件,默认为ES6版本

    1. "usingComponents": {
    2. "vtu-stepper": "/miniprogram_npm/vtuweapp/stepper/vtu-stepper"
    3. }

    代码演示

    基础用法

    1. <vtu-stepper value="{{value1}}" bind:change="bindChange"></vtu-stepper>
    2. Page({
    3. data: {
    4. value1: 3
    5. },
    6. bindChange (e) {
    7. this.setData({
    8. value1: e.detail
    9. })
    10. }
    11. });
    12.  

    尺寸大小

    1. <view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange"></vtu-stepper></view>
    2. <view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange" size="small"></vtu-stepper></view>
    3. <view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange" size="mini"></vtu-stepper></view>

    限制范围

    1. <vtu-stepper value="{{value1}}" min="-1" max="5" bind:change="bindChange"></vtu-stepper>

    全部禁用状态

    1. <vtu-stepper value="{{value1}}" disabled bind:change="bindChange"></vtu-stepper>

    自定义步数(步数2)

    1. <vtu-stepper value="{{value1}}" step="2"></vtu-stepper>

    异步处理

    1. <vtu-stepper value="{{value1}}" async="true" bind:change="bindAsyncChange"></vtu-stepper>
    2. Page({
    3. data: {
    4. value1: 3
    5. },
    6. bindAsyncChange (e) {
    7. let self = this
    8. wx.showLoading({
    9. title: '处理中...'
    10. })
    11. setTimeout(function() {
    12. self.setData({
    13. value1: e.detail
    14. })
    15. wx.hideLoading();
    16. }, 2000)
    17. }
    18. });
    19.  

    自定义宽度

    <vtu-stepper value="{{value1}}" input-width="80px"></vtu-stepper>
          

    自定义按钮样式

    <vtu-stepper value="{{value1}}" minus-btn-type="danger" plus-btn-type="primary" size="small"></vtu-stepper>
          

    组件参数

    Stepper 计步器 - 图1