feat: 增加单独禁用stepper input功能

This commit is contained in:
niunai
2017-09-26 16:57:53 +08:00
parent b632fa03c4
commit 178656e0fb
5 changed files with 47 additions and 8 deletions

View File

@@ -8,11 +8,11 @@
}">
</button>
<input
type="text"
type="number"
class="van-stepper__input"
:value="currentValue"
@input="handleInputChange"
:disabled="disabled">
:disabled="disabled || disableInput">
<button
@click="handleChange('plus')"
class="van-stepper__stepper van-stepper__plus"
@@ -42,6 +42,7 @@ export default {
default: 1
},
disabled: Boolean,
disableInput: Boolean,
defaultValue: {
type: [String, Number],
default: 1
@@ -91,8 +92,13 @@ export default {
methods: {
// 纠正value值
correctValue(value) {
value = Math.max(this.min, value);
value = Math.min(this.max, value);
if (Number.isNaN(value)) {
value = this.min;
} else {
value = Math.max(this.min, value);
value = Math.min(this.max, value);
}
return value;
},
handleInputChange(event) {