From a1af31826ebca4d1fee16c33b8329e0bf85812ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 13 Jul 2020 19:26:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dnumber=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/number.wc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/form/number.wc b/src/form/number.wc index ca9babb..f4318c9 100644 --- a/src/form/number.wc +++ b/src/form/number.wc @@ -247,18 +247,30 @@ export default class Number { val = 0 } this.props.value = val - this.__INPUT__.value = this.props.value + this.__INPUT__.value = val this._checkActionEnable() } _checkActionEnable() { var { max, min, value } = this.props + var n = value + + if (min !== null) { + if (min > n) { + n = min + } + this.__OUTER__.children[0].classList.toggle('disabled', value <= min) + } if (max !== null) { + if (max < n) { + n = max + } this.__OUTER__.children[2].classList.toggle('disabled', value >= max) } - if (min !== null) { - this.__OUTER__.children[0].classList.toggle('disabled', value <= min) + if (n !== value) { + this.props.value = n + this.__INPUT__.value = n } }