[improvement] Search&Field: add clear event. (#894)

This commit is contained in:
vv13 2018-11-12 19:02:23 +08:00 committed by neverland
parent 6060554fa6
commit 38cb8ca4f6
7 changed files with 17 additions and 1 deletions

View File

@ -25,5 +25,12 @@ Page({
title: '取消',
icon: 'none'
});
},
onClear() {
wx.showToast({
title: '清空',
icon: 'none'
});
}
});

View File

@ -15,6 +15,7 @@
bind:change="onChange"
bind:search="onSearch"
bind:cancel="onCancel"
bind:clear="onClear"
/>
</demo-block>

View File

@ -172,6 +172,7 @@ Page({
| bind:click-icon | 点击尾部图标时触发 | - |
| bind:focus | 输入框聚焦时触发 | - |
| bind:blur | 输入框失焦时触发 | - |
| bind:clear | 点击清空控件时触发 | - |
### Slot

View File

@ -115,6 +115,7 @@ VantComponent({
});
this.$emit('input', '');
this.$emit('change', '');
this.$emit('clear', '');
},
onConfirm() {

View File

@ -70,6 +70,7 @@ Search 支持自定义右侧取消按钮,使用名字为 action 的 slot 即
| bind:cancel | 取消搜索搜索时触发 | - |
| bind:focus | 输入框聚焦时触发 | - |
| bind:blur | 输入框失焦时触发 | - |
| bind:clear | 点击清空控件时触发 | - |
### Slot

View File

@ -47,6 +47,10 @@ VantComponent({
onBlur() {
this.$emit('blur');
}
},
onClear() {
this.$emit('clear');
},
}
});

View File

@ -23,6 +23,7 @@
bind:focus="onFocus"
bind:change="onChange"
bind:confirm="onSearch"
bind:clear="onClear"
/>
<view wx:if="{{ showAction || useActionSlot }}" class="van-search__action">
<slot wx:if="{{ useActionSlot }}" name="action" />