Commit 545add717e1ef47b6143d82b90434a5aac676261

Authored by yinheli
1 parent 7ec0b533

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: {
... ...