在react中使用,ant design 中的form 表单,在处理后台返回的错误信息时,报出You cannot set field before registering it.错误,虽然意思容易理解,但是解决困难?希望遇见相同问题的大神指点迷津。其中用到this.props.form.setFields导致出现的问题。
2 回答
吃鸡游戏
TA贡献1829条经验 获得超7个赞
render中的处理
render() { const {getFieldProps} = this.props.form; return (
<List>
<InputItem {...getFieldProps('username')}/>
<InputItem {...getFieldProps('password')}/>
</List>
);
}不在render中的话一般在componentDidMount中手动设置
this.props.form.setFieldsValue({username:'xxx',
password:'xxx'})添加回答
举报
0/150
提交
取消
