mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 18:00:27 +08:00
perf(Field): reduce input value assignment (#6489)
This commit is contained in:
parent
713c8e0101
commit
9adbfcb26c
@ -276,34 +276,26 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let { value } = target;
|
let { value } = target;
|
||||||
const { maxlength } = this;
|
const originValue = value;
|
||||||
|
|
||||||
// native maxlength not work when type is number
|
// native maxlength not work when type is number
|
||||||
|
const { maxlength } = this;
|
||||||
if (isDef(maxlength) && value.length > maxlength) {
|
if (isDef(maxlength) && value.length > maxlength) {
|
||||||
value = value.slice(0, maxlength);
|
value = value.slice(0, maxlength);
|
||||||
target.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type === 'number' || this.type === 'digit') {
|
if (this.type === 'number' || this.type === 'digit') {
|
||||||
const originValue = value;
|
|
||||||
const allowDot = this.type === 'number';
|
const allowDot = this.type === 'number';
|
||||||
|
|
||||||
value = formatNumber(value, allowDot);
|
value = formatNumber(value, allowDot);
|
||||||
|
|
||||||
if (value !== originValue) {
|
|
||||||
target.value = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.formatter) {
|
if (this.formatter) {
|
||||||
const originValue = value;
|
|
||||||
|
|
||||||
value = this.formatter(value);
|
value = this.formatter(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (value !== originValue) {
|
if (value !== originValue) {
|
||||||
target.value = value;
|
target.value = value;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user