Stepper计步器
引入
在app.json或index.json中引入组件,默认为ES6版本
"usingComponents": {
"vtu-stepper": "/miniprogram_npm/vtuweapp/stepper/vtu-stepper"
}
代码演示
基础用法
<vtu-stepper value="{{value1}}" bind:change="bindChange"></vtu-stepper>
Page({
data: {
value1: 3
},
bindChange (e) {
this.setData({
value1: e.detail
})
}
});
尺寸大小
<view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange"></vtu-stepper></view>
<view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange" size="small"></vtu-stepper></view>
<view class="stepperSpan"><vtu-stepper value="{{value1}}" bind:change="bindChange" size="mini"></vtu-stepper></view>
限制范围
<vtu-stepper value="{{value1}}" min="-1" max="5" bind:change="bindChange"></vtu-stepper>
全部禁用状态
<vtu-stepper value="{{value1}}" disabled bind:change="bindChange"></vtu-stepper>
自定义步数(步数2)
<vtu-stepper value="{{value1}}" step="2"></vtu-stepper>
异步处理
<vtu-stepper value="{{value1}}" async="true" bind:change="bindAsyncChange"></vtu-stepper>
Page({
data: {
value1: 3
},
bindAsyncChange (e) {
let self = this
wx.showLoading({
title: '处理中...'
})
setTimeout(function() {
self.setData({
value1: e.detail
})
wx.hideLoading();
}, 2000)
}
});
自定义宽度
<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>
组件参数