Commit 2fcd34da743e4db916cf76068fd1fbfb931c949f
Committed by
GitHub
Merge pull request #887 from yinheli/yinheli_2.0
[iView 2] input 支持 focus 方法
Showing
1 changed file
with
8 additions
and
0 deletions
Show diff stats
src/components/input/input.vue
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | <i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i> |
8 | 8 | </transition> |
9 | 9 | <input |
10 | + ref="input" | |
10 | 11 | :type="type" |
11 | 12 | :class="inputClasses" |
12 | 13 | :placeholder="placeholder" |
... | ... | @@ -194,6 +195,13 @@ |
194 | 195 | const maxRows = autosize.maxRows; |
195 | 196 | |
196 | 197 | this.textareaStyles = calcTextareaHeight(this.$refs.textarea, minRows, maxRows); |
198 | + }, | |
199 | + focus() { | |
200 | + if (this.type === 'textarea') { | |
201 | + this.$refs.textarea.focus(); | |
202 | + } else { | |
203 | + this.$refs.input.focus(); | |
204 | + } | |
197 | 205 | } |
198 | 206 | }, |
199 | 207 | watch: { | ... | ... |