I have just started using antd recently, and I have searched the Internet for a while, but it is not very clear. So save my usage.
1 Use initialValue
render() {
// @ts-ignore
const {location} = this.props;
const data = location.state;
let responsiblePeoplePhone = {};
if(data){
responsiblePeoplePhone={initialValue:data.responsiblePeoplePhone||''};
}
return( <FormItem
{...formItemLayout}
label="负责人联系方式"
required={true}
hasFeedback={true}
name="responsiblePeoplePhone"
{...responsiblePeoplePhone}
rules={[
{
required: true,
message: '请填写负责人联系方式',
},
{
pattern: ValidConst.phone,
message: '请输入正确的负责人联系方式',
},
]}
>
<Input />
</FormItem>
)
2 Use setFieldsValue
render() {
// @ts-ignore
const {location} = this.props;
const data = location.state;
// ref form
this.formRef.current.setFieldsValue({
responsiblePeoplePhone: data.responsiblePeoplePhone
})
return( <FormItem
{...formItemLayout}
label="负责人联系方式"
required={true}
hasFeedback={true}
name="responsiblePeoplePhone"
rules={[
{
required: true,
message: '请填写负责人联系方式',
},
{
pattern: ValidConst.phone,
message: '请输入正确的负责人联系方式',
},
]}
>
<Input />
</FormItem>
)
getData()
{ 获取输入值
const fieldsValue = this.formRef.current.getFieldsValue();
let result = {
responsiblePeoplePhone:
fieldsValue.responsiblePeoplePhone ,
};
return result;
}
Single-line editing operation
<Column
title="操作"
key="action"
dataIndex="action"
render={(_text,record: any) => <a onClick={()=>remindEdit(record)}>{isOpen?'停用':'启用'}</ a>}
/>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。