From 9adbfcb26ca43139ef6a243e8c603a9bca688d83 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 8 Jun 2020 19:57:25 +0800 Subject: [PATCH] perf(Field): reduce input value assignment (#6489) --- src/field/index.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/field/index.js b/src/field/index.js index 61fa5f82f..16ceb8003 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -276,33 +276,25 @@ export default createComponent({ } let { value } = target; - const { maxlength } = this; + const originValue = value; // native maxlength not work when type is number + const { maxlength } = this; if (isDef(maxlength) && value.length > maxlength) { value = value.slice(0, maxlength); - target.value = value; } if (this.type === 'number' || this.type === 'digit') { - const originValue = value; const allowDot = this.type === 'number'; - value = formatNumber(value, allowDot); - - if (value !== originValue) { - target.value = value; - } } if (this.formatter) { - const originValue = value; - value = this.formatter(value); + } - if (value !== originValue) { - target.value = value; - } + if (value !== originValue) { + target.value = value; } return value;