feat(Search): add some icon props (#2051)

This commit is contained in:
ShuaiKang Zhang 2019-09-19 11:27:26 +08:00 committed by neverland
parent 86ed4f6b3a
commit b6c8ef9fbf
3 changed files with 19 additions and 2 deletions

View File

@ -72,6 +72,10 @@
| placeholder | 输入框为空时占位符 | *string* | - | - |
| placeholder-style | 指定占位符的样式 | *string* | - | - |
| input-align | 输入框内容对齐方式,可选值为 `center` `right` | *string* | `left` | - |
| use-left-icon-slot | 是否使用输入框左侧图标 slot | *boolean* | `false` | - |
| use-right-icon-slot | 是否使用输入框右侧图标 slot | *boolean* | `false` | - |
| left-icon | 输入框左侧图标名称或图片链接,可选值见 Icon 组件如果设置了use-left-icon-slot则该属性无效 | *string* | `search` | - |
| right-icon | 输入框右侧图标名称或图片链接,可选值见 Icon 组件如果设置了use-right-icon-slot则该属性无效 | *string* | - | - |
### Events
@ -90,6 +94,8 @@
|-----------|-----------|
| action | 自定义搜索框右侧按钮,需要在`use-action-slot`为 true 时才会显示 |
| label | 自定义搜索框左侧文本 |
| left-icon | 自定义输入框左侧图标,需要在`use-left-icon-slot`为 true 时才会显示 |
| right-icon | 自定义输入框右侧图标,需要在`use-right-icon-slot`为 true 时才会显示 |
### 外部样式类

View File

@ -15,6 +15,13 @@ VantComponent({
inputAlign: String,
showAction: Boolean,
useActionSlot: Boolean,
useLeftIconSlot: Boolean,
useRightIconSlot: Boolean,
leftIcon: {
type: String,
value: 'search'
},
rightIcon: String,
placeholder: String,
placeholderStyle: String,
actionText: {

View File

@ -10,7 +10,8 @@
<van-field
type="search"
left-icon="search"
left-icon="{{ !useLeftIconSlot ? leftIcon : '' }}"
right-icon="{{ !useRightIconSlot ? rightIcon : '' }}"
focus="{{ focus }}"
error="{{ error }}"
border="{{ false }}"
@ -31,7 +32,10 @@
bind:change="onChange"
bind:confirm="onSearch"
bind:clear="onClear"
/>
>
<slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" />
<slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" />
</van-field>
</view>
<view