antd form某一项设置默认值initialValue,setFieldsValue

initialValue按照form说明那么写就行,在Form.Item中加入字段initialValue,但是注意,initialValue字段,如果你写的是比如data?.name这种形式,就是说初始是undefined之后再有确定值,那么单纯的initialValue是不能满足的。

解决方法:在你借口获取的数据那里,直接使用form.setFieldsValue才成功

 userRes = await getUserInfo({ 'userId': userId.data.userId }));
// form表单默认值
form.setFieldsValue({ phone: userRes?.data?.phone });

你可能感兴趣的:(菜鸡专属,前端,开发语言)