feat(Stepper): add new prop async-change @rex-zsd (#1133)

This commit is contained in:
rex 2018-12-24 20:23:27 +08:00 committed by neverland
parent 37b616251c
commit b85f044471
4 changed files with 23 additions and 3 deletions

View File

@ -1,3 +1,8 @@
import Page from '../../common/page';
import Toast from '../../dist/toast/toast';
Page();
Page({
onChange(event) {
Toast(`change: ${event.detail}`);
}
});

View File

@ -6,6 +6,15 @@
<van-stepper value="{{ value1 }}" disabled />
</demo-block>
<demo-block title="异步变更">
<van-stepper
value="{{ 5 }}"
integer
async-change
bind:change="onChange"
/>
</demo-block>
<demo-block title="高级用法" padding>
<van-stepper
value="{{ value2 }}"
@ -15,3 +24,5 @@
step="2"
/>
</demo-block>
<van-toast id="van-toast" />

View File

@ -52,6 +52,7 @@
| integer | 是否只允许输入整数 | `Boolean` | `false` |
| disabled | 是否禁用 | `Boolean` | `false` |
| disable-input | 是否禁用input框 | `Boolean` | `false` |
| async-change | 异步变更,为 `true` 时input值不变化仅触发事件 | `Boolean` | `false` |
### Event

View File

@ -17,6 +17,7 @@ VantComponent({
value: Number,
integer: Boolean,
disabled: Boolean,
asyncChange: Boolean,
disableInput: Boolean,
min: {
type: null,
@ -103,8 +104,10 @@ VantComponent({
this.onChange('plus');
},
triggerInput(value) {
this.set({ value });
triggerInput(value: string) {
this.set({
value: this.data.asyncChange ? this.data.value : value
});
this.$emit('change', value);
}
}