소스 검색

Merge pull request #449 from baiyaaaaa/feat-input

fix input type
杨奕 8 년 전
부모
커밋
2d3d9d3661
2개의 변경된 파일7개의 추가작업 그리고 22개의 파일을 삭제
  1. 0 2
      examples/docs/zh-cn/input.md
  2. 7 20
      packages/input/src/input.vue

+ 0 - 2
examples/docs/zh-cn/input.md

@@ -200,7 +200,6 @@
 ```html
 <el-input
   placeholder="请输入内容"
-  :number="true"
   v-model="input">
 </el-input>
 ```
@@ -636,7 +635,6 @@
 | disabled      | 禁用            | boolean         | — | false   |
 | size          | 输入框尺寸,只在 `type!="textarea"` 时有效      | string          | large, small, mini  | — |
 | icon          | 输入框尾部图标    | string          | — | — |
-| number        | 指定 model 值为 number 类型  |  boolean | — |  false   |
 | rows          | 输入框行数,只对 `type="textarea"` 有效  |  number | — |  2   |
 | autosize      | 自适应内容高度,只对 `type="textarea"` 有效,可传入对象,如,{ minRows: 2, maxRows: 6 }  |  boolean/object | — |  false   |
 

+ 7 - 20
packages/input/src/input.vue

@@ -13,27 +13,9 @@
         <slot name="prepend"></slot>
       </div>
       <input
-        v-if="type === 'text'"
+        v-if="type !== 'textarea'"
         class="el-input__inner"
-        v-model="currentValue"
-        type="text"
-        :name="name"
-        :placeholder="placeholder"
-        :disabled="disabled"
-        :readonly="readonly"
-        :number="number"
-        :maxlength="maxlength"
-        :minlength="minlength"
-        :autocomplete="autoComplete"
-        ref="input"
-        @focus="handleFocus"
-        @blur="handleBlur"
-      >
-      <input
-        v-if="type === 'password'"
-        class="el-input__inner"
-        v-model="currentValue"
-        type="password"
+        :type="type"
         :name="name"
         :placeholder="placeholder"
         :disabled="disabled"
@@ -42,7 +24,9 @@
         :maxlength="maxlength"
         :minlength="minlength"
         :autocomplete="autoComplete"
+        :value="value"
         ref="input"
+        @input="handleInput"
         @focus="handleFocus"
         @blur="handleBlur"
       >
@@ -151,6 +135,9 @@
       },
       handleFocus(ev) {
         this.$emit('focus', ev);
+      },
+      handleInput(ev) {
+        this.currentValue = ev.target.value;
       }
     },