mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
[bugfix] Filed number type value filter (#386)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
class="van-field__control"
|
||||
:type="type"
|
||||
:value="value"
|
||||
@keypress="onKeypress"
|
||||
@input="onInput"
|
||||
@focus="$emit('focus')"
|
||||
@blur="$emit('blur')"
|
||||
@@ -111,6 +112,17 @@ export default {
|
||||
this.onIconClick();
|
||||
},
|
||||
|
||||
onKeypress(event) {
|
||||
if (this.type === 'number') {
|
||||
const { keyCode } = event;
|
||||
const allowPoint = this.value.indexOf('.') === -1;
|
||||
const isValidKey = (keyCode >= 48 && keyCode <= 57) || (keyCode === 46 && allowPoint);
|
||||
if (!isValidKey) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
adjustSize() {
|
||||
const el = this.$refs.textarea;
|
||||
el.style.height = 'auto';
|
||||
|
Reference in New Issue
Block a user