Commit fa66bfb19f55aece004448d0aaea59e649dc9a49
1 parent
7f08fb51
add watchers for min and max in inputNumber
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
examples/routers/input-number.vue
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - <Input-number :max="10" name="he" :min="-1" v-model="v1" :autofocus="autofocus"></Input-number> | 3 | + <Input-number :max="max" name="he" :min="-1" v-model="v1" :autofocus="autofocus"></Input-number> |
4 | {{ v1 }} | 4 | {{ v1 }} |
5 | <div @click="c">change v1</div> | 5 | <div @click="c">change v1</div> |
6 | + <div @click="changeMax">change max</div> | ||
6 | <Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number> | 7 | <Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number> |
7 | <Input-number :max="10" :min="1" v-model="obj.v"></Input-number> | 8 | <Input-number :max="10" :min="1" v-model="obj.v"></Input-number> |
8 | </div> | 9 | </div> |
@@ -14,6 +15,7 @@ | @@ -14,6 +15,7 @@ | ||
14 | return { | 15 | return { |
15 | v1: 1, | 16 | v1: 1, |
16 | v2: 1, | 17 | v2: 1, |
18 | + max: 10, | ||
17 | autofocus: true, | 19 | autofocus: true, |
18 | obj: { | 20 | obj: { |
19 | 21 | ||
@@ -24,6 +26,9 @@ | @@ -24,6 +26,9 @@ | ||
24 | methods: { | 26 | methods: { |
25 | c () { | 27 | c () { |
26 | this.v1 = 5; | 28 | this.v1 = 5; |
29 | + }, | ||
30 | + changeMax () { | ||
31 | + this.max++; | ||
27 | } | 32 | } |
28 | } | 33 | } |
29 | }; | 34 | }; |
src/components/input-number/input-number.vue
@@ -273,6 +273,12 @@ | @@ -273,6 +273,12 @@ | ||
273 | }, | 273 | }, |
274 | currentValue (val) { | 274 | currentValue (val) { |
275 | this.changeVal(val); | 275 | this.changeVal(val); |
276 | + }, | ||
277 | + min () { | ||
278 | + this.changeVal(this.currentValue); | ||
279 | + }, | ||
280 | + max () { | ||
281 | + this.changeVal(this.currentValue); | ||
276 | } | 282 | } |
277 | } | 283 | } |
278 | }; | 284 | }; |