[Improvement] Search: support native input attrs (#418)

This commit is contained in:
neverland 2017-12-12 20:00:19 +08:00 committed by GitHub
parent e2318391dc
commit 1fd157e9f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -77,7 +77,7 @@ Textarea Filed can be auto resize when has `autosize` prop
``` ```
### API ### API
Filed support all native properties of input tagsuch as `maxlength``placeholder``readonly` Filed support all native properties of input tagsuch as `maxlength``placeholder``readonly``autofocus`
| Attribute | Description | Type | Default | Accepted Values | | Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|

View File

@ -55,6 +55,7 @@ Use `action` slot to custom right button, `cancel` event will no longer be trigg
``` ```
### API ### API
Search support all native properties of input tagsuch as `maxlength``placeholder``readonly``autofocus`
| Attribute | Description | Type | Default | Accepted Values | | Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|

View File

@ -79,7 +79,7 @@ Vue.use(Field);
``` ```
### API ### API
Filed 默认支持 Input 标签所有的原生属性,比如 `maxlength``placeholder``readonly` Filed 默认支持 Input 标签所有的原生属性,比如 `maxlength``placeholder``readonly``autofocus`
| 参数 | 说明 | 类型 | 默认值 | 可选值 | | 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|

View File

@ -46,10 +46,10 @@ Tips: 在 `van-search` 外层增加 form 标签,并且 action 不为空,即
``` ```
### API ### API
Search 默认支持 Input 标签所有的原生属性,比如 `maxlength``placeholder``readony``autofocus`
| 参数 | 说明 | 类型 | 默认值 | 可选值 | | 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------| |-----------|-----------|-----------|-------------|-------------|
| placeholder | `input``placeholder`文案 | `String` | - | - |
| background | 搜索框背景色 | `String` | `#f2f2f2` | 所有浏览器支持的颜色描述 | | background | 搜索框背景色 | `String` | `#f2f2f2` | 所有浏览器支持的颜色描述 |
| showAction | 是否在搜索框右侧显示取消按钮 | `Boolean` | false | - | | showAction | 是否在搜索框右侧显示取消按钮 | `Boolean` | false | - |

View File

@ -8,14 +8,14 @@
<input <input
type="search" type="search"
class="van-search__input" class="van-search__input"
v-bind="$attrs"
v-refocus="focusStatus" v-refocus="focusStatus"
:value="value" :value="value"
:placeholder="placeholder"
@input="onInput" @input="onInput"
@focus="onFocus" @focus="onFocus"
@keypress.enter.prevent="onSearch" @keypress.enter.prevent="onSearch"
> >
<icon name="clear" @click="onClean" v-show="isFocus" /> <icon name="clear" v-show="isFocus && value" @click="onClean" />
</div> </div>
<div class="van-search__action" v-if="showAction"> <div class="van-search__action" v-if="showAction">
<slot name="action"> <slot name="action">
@ -35,7 +35,6 @@ export default create({
props: { props: {
value: String, value: String,
showAction: Boolean, showAction: Boolean,
placeholder: String,
background: { background: {
type: String, type: String,
default: '#f2f2f2' default: '#f2f2f2'