description:
Click the button to assign a value to InputItem, the input component of antd-mobile. The method is this.props.form.setFieldsValue ()
, but the assignment is not successful and the value does not appear in the input box
related codes
<List>
<InputItem className="customized-input"
{...getFieldProps("money", {
normalize: (v, prev) => {
if (v && !/^(([1-9]\d*)|0)(\.\d{0,2}?)?$/.test(v)) {
if(v === "."){
return "0.";
}
return prev;
}
return v;
},
rules: [
{validator: this.validateAmount}
],
onChange: (v) => this.getTradeShare(v)
})}
type={type}
maxLength={8}
placeholder={placeholder}
ref={el => this.inputRef = el}
onVirtualKeyboardConfirm={v => this.getTradeShare(v)}
clear
moneyKeyboardAlign="left"
moneyKeyboardWrapProps={moneyKeyboardWrapProps}
>
</InputItem>
</List>
setAmount(amount) {
this.props.form.setFields({
"money" : amount
});
}
expected results
Click the button to assign the value successfully, the value is displayed in the input box, and the verification rule is triggered
actual results
assignment is not successful, the input box does not display a numeric value, and the verification rule is not triggered