Переглянути джерело

support button autofocus && autofocus message box confirm button

baiyaaaaa 8 роки тому
батько
коміт
2e77e5a50b

+ 1 - 0
examples/docs/zh-cn/button.md

@@ -191,4 +191,5 @@ Button 组件提供除了默认值以外的三种尺寸,可以在不同场景
 | plain     | 是否朴素按钮   | Boolean    | true,false | false   |
 | disabled  | 禁用    | boolean   | true, false   | false   |
 | icon  | 图标,已有的图标库中的图标名 | string   |  —  |  —  |
+| autofocus  | 是否默认聚焦 | boolean   |  —  |  false  |
 | native-type | 原生 type 属性 | string | button,submit,reset | button |

+ 5 - 12
packages/button/src/button.vue

@@ -1,6 +1,7 @@
 <template>
   <button :disabled="disabled" class="el-button"
     @click="handleClick"
+    :autofocus="autofocus"
     :type="nativeType"
     :class="[
       type ? 'el-button--' + type : '',
@@ -35,18 +36,10 @@
         type: String,
         default: 'button'
       },
-      loading: {
-        type: Boolean,
-        default: false
-      },
-      disabled: {
-        type: Boolean,
-        default: false
-      },
-      plain: {
-        type: Boolean,
-        default: false
-      }
+      loading: Boolean,
+      disabled: Boolean,
+      plain: Boolean,
+      autofocus: Boolean
     },
 
     methods: {

+ 1 - 1
packages/message-box/src/main.vue

@@ -16,7 +16,7 @@
         </div>
         <div class="el-message-box__btns">
           <el-button :class="[ cancelButtonClasses ]" v-show="showCancelButton" @click.native="handleAction('cancel')">{{ cancelButtonText }}</el-button>
-          <el-button :class="[ confirmButtonClasses ]" v-show="showConfirmButton" @click.native="handleAction('confirm')">{{ confirmButtonText }}</el-button>
+          <el-button autofocus :class="[ confirmButtonClasses ]" v-show="showConfirmButton" @click.native="handleAction('confirm')">{{ confirmButtonText }}</el-button>
         </div>
       </div>
     </transition>