mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[new feature] Field: 增加事件 focus
, blur
的参数 (#956)
This commit is contained in:
parent
98b00038f9
commit
be2f53c346
@ -173,8 +173,8 @@ Page({
|
|||||||
| bind:change | 输入内容时触发 | value: 当前输入值 |
|
| bind:change | 输入内容时触发 | value: 当前输入值 |
|
||||||
| bind:confirm | 点击完成按钮时触发 | value: 当前输入值 |
|
| bind:confirm | 点击完成按钮时触发 | value: 当前输入值 |
|
||||||
| bind:click-icon | 点击尾部图标时触发 | - |
|
| bind:click-icon | 点击尾部图标时触发 | - |
|
||||||
| bind:focus | 输入框聚焦时触发 | - |
|
| bind:focus | 输入框聚焦时触发 | event.detail.value: 当前输入值; <br>event.detail.height: 键盘高度(在基础库 1.9.90 起支持) |
|
||||||
| bind:blur | 输入框失焦时触发 | - |
|
| bind:blur | 输入框失焦时触发 | event.detail.value: 当前输入值; <br>event.detail.cursor: 游标位置(如果 `type` 不为 `textarea`,值为 `0`) |
|
||||||
| bind:clear | 点击清空控件时触发 | - |
|
| bind:clear | 点击清空控件时触发 | - |
|
||||||
|
|
||||||
### Slot
|
### Slot
|
||||||
|
@ -87,17 +87,19 @@ VantComponent({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFocus() {
|
onFocus(event: Weapp.Event) {
|
||||||
this.$emit('focus');
|
const { value = '', height = 0 } = event.detail || {};
|
||||||
|
this.$emit('focus', { value, height });
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
this.setData({
|
this.setData({
|
||||||
showClear: this.getShowClear()
|
showClear: this.getShowClear()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlur() {
|
onBlur(event: Weapp.Event) {
|
||||||
|
const { value = '', cursor = 0 } = event.detail || {};
|
||||||
|
this.$emit('blur', { value, cursor });
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
this.$emit('blur');
|
|
||||||
this.setData({
|
this.setData({
|
||||||
showClear: this.getShowClear()
|
showClear: this.getShowClear()
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user