mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] Field: support native events (#421)
This commit is contained in:
parent
51ce4d0843
commit
e2ec1ecd13
@ -90,6 +90,7 @@ Filed support all native properties of input tag,such as `maxlength`、`placeh
|
|||||||
| icon | Right side Icon name | `String` | - | - |
|
| icon | Right side Icon name | `String` | - | - |
|
||||||
|
|
||||||
### Event
|
### Event
|
||||||
|
Filed support all native events of input tag,such as `keypress`、`keyup`
|
||||||
|
|
||||||
| Event | Description | Parameters |
|
| Event | Description | Parameters |
|
||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
|
@ -92,6 +92,7 @@ Filed 默认支持 Input 标签所有的原生属性,比如 `maxlength`、`pla
|
|||||||
| icon | 输入框尾部图标 | `String` | - | Icon 组件支持的类型 |
|
| icon | 输入框尾部图标 | `String` | - | Icon 组件支持的类型 |
|
||||||
|
|
||||||
### Event
|
### Event
|
||||||
|
Filed 默认支持 Input 标签所有的原生事件,比如 `keypress`、`keyup` 等
|
||||||
|
|
||||||
| 事件名称 | 说明 | 回调参数 |
|
| 事件名称 | 说明 | 回调参数 |
|
||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
|
@ -16,23 +16,18 @@
|
|||||||
<textarea
|
<textarea
|
||||||
v-if="type === 'textarea'"
|
v-if="type === 'textarea'"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
v-on="listeners"
|
||||||
ref="textarea"
|
ref="textarea"
|
||||||
class="van-field__control"
|
class="van-field__control"
|
||||||
:value="value"
|
:value="value"
|
||||||
@input="onInput"
|
|
||||||
@focus="$emit('focus')"
|
|
||||||
@blur="$emit('blur')"
|
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
v-on="listeners"
|
||||||
class="van-field__control"
|
class="van-field__control"
|
||||||
:type="type"
|
:type="type"
|
||||||
:value="value"
|
:value="value"
|
||||||
@keypress="onKeypress"
|
|
||||||
@input="onInput"
|
|
||||||
@focus="$emit('focus')"
|
|
||||||
@blur="$emit('blur')"
|
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="hasIcon"
|
v-if="hasIcon"
|
||||||
@ -98,6 +93,14 @@ export default create({
|
|||||||
computed: {
|
computed: {
|
||||||
hasIcon() {
|
hasIcon() {
|
||||||
return this.$slots.icon || this.icon;
|
return this.$slots.icon || this.icon;
|
||||||
|
},
|
||||||
|
|
||||||
|
listeners() {
|
||||||
|
return {
|
||||||
|
...this.$listeners,
|
||||||
|
input: this.onInput,
|
||||||
|
keypress: this.onKeypress
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -120,6 +123,7 @@ export default create({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.$emit('keypress', event);
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustSize() {
|
adjustSize() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user