Skip to content

Commit

Permalink
fix: 修改数据更新逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
gooolh committed Dec 25, 2023
1 parent 6550641 commit acdc5a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/amis/src/renderers/Form/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,17 @@ export default class NumberControl extends React.Component<

componentDidUpdate(prevProps: NumberProps) {
const unit = this.getUnit();
const value = this.props.value;
const {value, formInited, onChange, setPrinstineValue} = this.props;
if (
value != null &&
(typeof value === 'string' || typeof value === 'number') &&
unit &&
!String(value).endsWith(unit)
) {
this.props.setPrinstineValue(this.getValue(value));
const finalValue = this.getValue(value);
formInited === false
? setPrinstineValue?.(finalValue)
: onChange?.(finalValue);
}
// 匹配 数字 + ?字符
const reg = /^([-+]?(([1-9]\d*\.?\d*)|(0\.\d*[1-9]))[^\d\.]*)$/;
Expand Down

0 comments on commit acdc5a2

Please sign in to comment.