Commit fa66bfb19f55aece004448d0aaea59e649dc9a49

Authored by Rijn
1 parent 7f08fb51

add watchers for min and max in inputNumber

examples/routers/input-number.vue
1 1 <template>
2 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 4 {{ v1 }}
5 5 <div @click="c">change v1</div>
  6 + <div @click="changeMax">change max</div>
6 7 <Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number>
7 8 <Input-number :max="10" :min="1" v-model="obj.v"></Input-number>
8 9 </div>
... ... @@ -14,6 +15,7 @@
14 15 return {
15 16 v1: 1,
16 17 v2: 1,
  18 + max: 10,
17 19 autofocus: true,
18 20 obj: {
19 21  
... ... @@ -24,6 +26,9 @@
24 26 methods: {
25 27 c () {
26 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 273 },
274 274 currentValue (val) {
275 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 };
... ...