Commit 07e122c682f96fa81e6322d4ef9139e928c75c7a

Authored by Aresn
Committed by GitHub
2 parents b51a3861 3d4fd6df

Merge pull request #3395 from angela-1/dev-inputnumber

实现InputNumber获取焦点时选中已有值,增加on-focus的返回值event。
examples/routers/input-number.vue
... ... @@ -48,6 +48,8 @@
48 48  
49 49 <InputNumber v-model="valueNull" @on-change="change" style="width: 200px"></InputNumber>
50 50 <InputNumber v-model="valueNull" @on-change="change" :formatter="formatter" :parser="parser" style="width: 200px"></InputNumber>
  51 +
  52 + <InputNumber v-model="value2" @on-focus="focus" style="width: 200px"></InputNumber>
51 53 </div>
52 54 </template>
53 55 <script>
... ... @@ -64,6 +66,9 @@
64 66 }
65 67 },
66 68 methods: {
  69 + focus (e) {
  70 + e.target.select()
  71 + },
67 72 change (v) {
68 73 console.log(v)
69 74 }
... ...
src/components/input-number/input-number.vue
... ... @@ -26,6 +26,7 @@
26 26 @blur="blur"
27 27 @keydown.stop="keyDown"
28 28 @input="change"
  29 + @mouseup="preventDefault"
29 30 @change="change"
30 31 :readonly="readonly || !editable"
31 32 :name="name"
... ... @@ -250,9 +251,9 @@
250 251 this.dispatch('FormItem', 'on-form-change', val);
251 252 });
252 253 },
253   - focus () {
  254 + focus (event) {
254 255 this.focused = true;
255   - this.$emit('on-focus');
  256 + this.$emit('on-focus', event);
256 257 },
257 258 blur () {
258 259 this.focused = false;
... ...