我們在做表單的時候經常會遇到一個場景需要數組對象格式的數據,例如我們填寫公司成員信息,如下圖:

我們需要的數據格式是數組對象,這時我們在getFieldDecorator要如何取名字呢?
<Form.Item style={{ margin: 0 }}>
{getFieldDecorator(`content[${index}].name`, {
rules: [
{
required:true,
message: '請輸入姓名!',
},
],
initialValue:...,
})(<Input />)}
</Form.Item>
<Form.Item style={{ margin: 0 }}>
{getFieldDecorator(`content[${index}].workId`, {
rules: [
{
required:true,
message: '請輸入工號!',
},
],
initialValue:...,
})(<Input />)}
</Form.Item>
此時我們如果想獲取這個數組對象內容可以通過:
let param = getFieldsValue(['content'])獲取
