fix: auto-fill for 0

This commit is contained in:
RB 2022-04-26 13:18:39 +08:00
parent 39ab712324
commit 5b4708c10e

View file

@ -766,7 +766,7 @@ class RbFormNumber extends RbFormText {
className={`form-control form-control-sm ${this.state.hasError ? 'is-invalid' : ''}`}
title={this.state.hasError}
type="text"
value={this._removeComma(value) || ''}
value={this._removeComma(value)}
onChange={(e) => this.handleChange(e, this.props.readonly ? false : true)}
// onBlur={this.props.readonly ? null : () => this.checkValue()}
readOnly={this.props.readonly}
@ -837,7 +837,8 @@ class RbFormNumber extends RbFormText {
// 移除千分为位
_removeComma(n) {
if (n) return (n + '').replace(/,/g, '')
return n
else if (isNaN(n)) return ''
else return n // `0`
}
}