Commit 2fcd34da743e4db916cf76068fd1fbfb931c949f

Authored by Aresn
Committed by GitHub
2 parents 7ec0b533 545add71

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,6 +7,7 @@
7 <i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i> 7 <i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i>
8 </transition> 8 </transition>
9 <input 9 <input
  10 + ref="input"
10 :type="type" 11 :type="type"
11 :class="inputClasses" 12 :class="inputClasses"
12 :placeholder="placeholder" 13 :placeholder="placeholder"
@@ -194,6 +195,13 @@ @@ -194,6 +195,13 @@
194 const maxRows = autosize.maxRows; 195 const maxRows = autosize.maxRows;
195 196
196 this.textareaStyles = calcTextareaHeight(this.$refs.textarea, minRows, maxRows); 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 watch: { 207 watch: {