Commit 5d5f8dc8c668b307b3662378154152785d8b4d2d

Authored by Aresn
Committed by GitHub
2 parents f1f8ca05 8d3a02a5

Merge pull request #780 from nosixer/2.0

Input 组件增加autofocus属性
examples/routers/input-number.vue
1 1 <template>
2 2 <div>
3   - <Input-number :max="10" :min="-1" v-model="v1"></Input-number>
  3 + <Input-number :max="10" :min="-1" v-model="v1" :autofocus="autofocus"></Input-number>
4 4 {{ v1 }}
5 5 <div @click="c">change v1</div>
6 6 <Input-number disabled :max="10" :min="1" :step="1.2" v-model="v2"></Input-number>
... ... @@ -12,7 +12,8 @@
12 12 data () {
13 13 return {
14 14 v1: 1,
15   - v2: 1
  15 + v2: 1,
  16 + autofocus: true
16 17 };
17 18 },
18 19 computed: {},
... ...
examples/routers/input.vue
1 1 <template>
2 2 <div style="width: 300px;">
3   - <i-input v-model="value11" icon="ios-clock-outline">
  3 + <i-input v-model="value11" icon="ios-clock-outline" :autofocus="autofocus">
4 4 <span slot="prepend">.com</span>
5 5 </i-input>
6 6 <i-input v-model="value11" icon="ios-clock-outline">
... ... @@ -17,7 +17,8 @@
17 17 value13: '',
18 18 select1: 'http',
19 19 select2: 'com',
20   - select3: 'day'
  20 + select3: 'day',
  21 + autofocus: true
21 22 }
22 23 }
23 24 }
... ...
src/components/input-number/input-number.vue
... ... @@ -19,6 +19,7 @@
19 19 :class="inputClasses"
20 20 :disabled="disabled"
21 21 autocomplete="off"
  22 + :autofocus="autofocus"
22 23 @focus="focus"
23 24 @blur="blur"
24 25 @keydown.stop="keyDown"
... ... @@ -89,6 +90,10 @@
89 90 disabled: {
90 91 type: Boolean,
91 92 default: false
  93 + },
  94 + autofocus: {
  95 + type: Boolean,
  96 + default: false
92 97 }
93 98 },
94 99 data () {
... ...
src/components/input/input.vue
... ... @@ -16,6 +16,7 @@
16 16 :name="name"
17 17 :value="currentValue"
18 18 :number="number"
  19 + :autofocus="autofocus"
19 20 @keyup.enter="handleEnter"
20 21 @focus="handleFocus"
21 22 @blur="handleBlur"
... ... @@ -98,6 +99,10 @@
98 99 number: {
99 100 type: Boolean,
100 101 default: false
  102 + },
  103 + autofocus: {
  104 + type: Boolean,
  105 + default: false
101 106 }
102 107 },
103 108 data () {
... ...