From ac6abf67b7fc98e71bc0a0186ed572a4219c2208 Mon Sep 17 00:00:00 2001 From: Yao Date: Sat, 15 Jul 2017 21:30:36 +0800 Subject: [PATCH] =?UTF-8?q?Field=20=E5=A2=9E=E5=8A=A0blur=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=20&&=20Field=20=E6=94=AF=E6=8C=81=E5=B0=BE=E9=83=A8ic?= =?UTF-8?q?on=20(#53)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/examples-docs/field.md | 21 ++++++++++++++++++++- packages/field/src/field.vue | 16 +++++++++++++++- packages/vant-css/src/field.css | 9 +++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/examples-docs/field.md b/docs/examples-docs/field.md index c2223ff99..5dc74c679 100644 --- a/docs/examples-docs/field.md +++ b/docs/examples-docs/field.md @@ -14,6 +14,15 @@ export default { return { username: 'zhangmin' }; + }, + methods: { + onIconClick() { + this.username = ''; + }, + + onFieldBlur() { + console.log('blured'); + } } }; @@ -62,7 +71,15 @@ export default { :::demo 基础用法 ```html - + @@ -145,4 +162,6 @@ export default { | rows | textarea rows | `string`, `number` | | | | cols | textarea cols | `string`, `number` | | | | autosize | 自动调整高度(仅支持textarea) | `boolean` | `false` | `true`, `false` | +| icon | 输入框尾部图标 | `string` | | icon中支持的类型 | +| onIconClick | 点击图标的回调函数 | `function` | | | diff --git a/packages/field/src/field.vue b/packages/field/src/field.vue index cbc38a10b..c6eda14b1 100644 --- a/packages/field/src/field.vue +++ b/packages/field/src/field.vue @@ -17,6 +17,7 @@ class="van-field__control" v-model="currentValue" @focus="handleInputFocus" + @blur="handleInputBlur" :placeholder="placeholder" :maxlength="maxlength" :disabled="disabled" @@ -30,23 +31,27 @@ :value="currentValue" @input="handleInput" @focus="handleInputFocus" + @blur="handleInputBlur" :type="type" :placeholder="placeholder" :maxlength="maxlength" :disabled="disabled" :readonly="readonly"> +