feat(Search): add clear-icon prop (#8439)

This commit is contained in:
neverland 2021-04-01 09:53:54 +08:00 committed by GitHub
parent 2a065f85ef
commit 10d2517581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 2 deletions

View File

@ -247,6 +247,7 @@ Use `input-align` prop to align the input value.
| required | Whether to show required mark | _boolean_ | `false` | | required | Whether to show required mark | _boolean_ | `false` |
| center | Whether to center content vertically | _boolean_ | `true` | | center | Whether to center content vertically | _boolean_ | `true` |
| clearable | Whether to be clearable | _boolean_ | `false` | | clearable | Whether to be clearable | _boolean_ | `false` |
| clear-icon `v3.0.12` | Clear icon name | _string_ | `clear` |
| clear-trigger | When to display the clear icon, `always` means to display the icon when value is not empty, `focus` means to display the icon when input is focused | _string_ | `focus` | | clear-trigger | When to display the clear icon, `always` means to display the icon when value is not empty, `focus` means to display the icon when input is focused | _string_ | `focus` |
| clickable | Whether to show click feedback when clicked | _boolean_ | `false` | | clickable | Whether to show click feedback when clicked | _boolean_ | `false` |
| is-link | Whether to show link icon | _boolean_ | `false` | | is-link | Whether to show link icon | _boolean_ | `false` |
@ -265,7 +266,6 @@ Use `input-align` prop to align the input value.
| autosize | Textarea auto resizecan accpet an object,<br>e.g. { maxHeight: 100, minHeight: 50 } | _boolean \| object_ | `false` | | autosize | Textarea auto resizecan accpet an object,<br>e.g. { maxHeight: 100, minHeight: 50 } | _boolean \| object_ | `false` |
| left-icon | Left side icon name | _string_ | - | | left-icon | Left side icon name | _string_ | - |
| right-icon | Right side icon name | _string_ | - | | right-icon | Right side icon name | _string_ | - |
| clear-icon `v3.0.12` | Clear icon name | _string_ | `clear` |
| icon-prefix | Icon className prefix | _string_ | `van-icon` | | icon-prefix | Icon className prefix | _string_ | `van-icon` |
| rules | Form validation rules | _Rule[]_ | - | | rules | Form validation rules | _Rule[]_ | - |
| autocomplete `v3.0.3` | [autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) attribute of native input element | _string_ | - | | autocomplete `v3.0.3` | [autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) attribute of native input element | _string_ | - |

View File

@ -270,6 +270,7 @@ export default {
| required | 是否显示表单必填星号 | _boolean_ | `false` | | required | 是否显示表单必填星号 | _boolean_ | `false` |
| center | 是否使内容垂直居中 | _boolean_ | `false` | | center | 是否使内容垂直居中 | _boolean_ | `false` |
| clearable | 是否启用清除图标,点击清除图标后会清空输入框 | _boolean_ | `false` | | clearable | 是否启用清除图标,点击清除图标后会清空输入框 | _boolean_ | `false` |
| clear-icon `v3.0.12` | 清除[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `clear` |
| clear-trigger | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` | | clear-trigger | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` |
| clickable | 是否开启点击反馈 | _boolean_ | `false` | | clickable | 是否开启点击反馈 | _boolean_ | `false` |
| is-link | 是否展示右侧箭头并开启点击反馈 | _boolean_ | `false` | | is-link | 是否展示右侧箭头并开启点击反馈 | _boolean_ | `false` |
@ -288,7 +289,6 @@ export default {
| autosize | 是否自适应内容高度,只对 textarea 有效,<br>可传入对象,如 { maxHeight: 100, minHeight: 50 }<br>单位为`px` | _boolean \| object_ | `false` | | autosize | 是否自适应内容高度,只对 textarea 有效,<br>可传入对象,如 { maxHeight: 100, minHeight: 50 }<br>单位为`px` | _boolean \| object_ | `false` |
| left-icon | 左侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - | | left-icon | 左侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
| right-icon | 右侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - | | right-icon | 右侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
| clear-icon `v3.0.12` | 清除[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `clear` |
| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | | icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` |
| rules | 表单校验规则,详见 [Form 组件](#/zh-CN/form#rule-shu-ju-jie-gou) | _Rule[]_ | - | | rules | 表单校验规则,详见 [Form 组件](#/zh-CN/form#rule-shu-ju-jie-gou) | _Rule[]_ | - |
| autocomplete `v3.0.3` | input 标签原生的[自动完成属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) | _string_ | - | | autocomplete `v3.0.3` | input 标签原生的[自动完成属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) | _string_ | - |

View File

@ -120,6 +120,7 @@ Use `action` slot to custom right button, `cancel` event will no longer be Emitt
| maxlength | Max length of value | _number \| string_ | - | | maxlength | Max length of value | _number \| string_ | - |
| placeholder | Placeholder | _string_ | - | | placeholder | Placeholder | _string_ | - |
| clearable | Whether to be clearable | _boolean_ | `true` | | clearable | Whether to be clearable | _boolean_ | `true` |
| clear-icon `v3.0.12` | Clear icon name | _string_ | `clear` |
| clear-trigger | When to display the clear icon, `always` means to display the icon when value is not empty, `focus` means to display the icon when input is focused | _string_ | `focus` | | clear-trigger | When to display the clear icon, `always` means to display the icon when value is not empty, `focus` means to display the icon when input is focused | _string_ | `focus` |
| autofocus | Whether to auto focus, unsupported in iOS | _boolean_ | `false` | | autofocus | Whether to auto focus, unsupported in iOS | _boolean_ | `false` |
| show-action | Whether to show right action button | _boolean_ | `false` | | show-action | Whether to show right action button | _boolean_ | `false` |

View File

@ -136,6 +136,7 @@ export default {
| maxlength | 输入的最大字符数 | _number \| string_ | - | | maxlength | 输入的最大字符数 | _number \| string_ | - |
| placeholder | 占位提示文字 | _string_ | - | | placeholder | 占位提示文字 | _string_ | - |
| clearable | 是否启用清除图标,点击清除图标后会清空输入框 | _boolean_ | `true` | | clearable | 是否启用清除图标,点击清除图标后会清空输入框 | _boolean_ | `true` |
| clear-icon `v3.0.12` | 清除[图标名称](#/zh-CN/icon)或图片链接 | _string_ | `clear` |
| clear-trigger | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` | | clear-trigger | 显示清除图标的时机,`always` 表示输入框不为空时展示,<br>`focus` 表示输入框聚焦且不为空时展示 | _string_ | `focus` |
| autofocus | 是否自动聚焦iOS 系统不支持该属性 | _boolean_ | `false` | | autofocus | 是否自动聚焦iOS 系统不支持该属性 | _boolean_ | `false` |
| show-action | 是否在搜索框右侧显示取消按钮 | _boolean_ | `false` | | show-action | 是否在搜索框右侧显示取消按钮 | _boolean_ | `false` |

View File

@ -28,6 +28,7 @@ export default defineComponent({
props: { props: {
label: String, label: String,
clearIcon: String,
rightIcon: String, rightIcon: String,
modelValue: String, modelValue: String,
actionText: String, actionText: String,
@ -121,6 +122,7 @@ export default defineComponent({
ref={filedRef} ref={filedRef}
type="search" type="search"
border={false} border={false}
clearIcon={props.clearIcon}
onKeypress={onKeypress} onKeypress={onKeypress}
{...fieldAttrs} {...fieldAttrs}
{...{ 'onUpdate:modelValue': onInput }} {...{ 'onUpdate:modelValue': onInput }}