antd的form.list中如何setFieldsValue

主要就这几行代码:

const newData = [
  ...getFieldValue("areaData")
];
newData[field.key] = {
  ...newData[field.key],
  typeData: testData
};
setFieldsValue({
  areaData: newData
});

详情看下面:

import React, { useState } from "react";
import "./styles.css";
import { Button, Drawer, Form, Card } from "antd";
import "antd/dist/antd.css";
import Proform, { ProFormSelect } from "@ant-design/pro-form";
const areaTypeList = {
  "1": "测试1",
  "2": "测试2"
};
export default function App() {
  const [visible, setVisible] = useState(false);
  const [dynamicAreaForm] = Form.useForm();
  return (
    
setVisible(false)}> { console.log("area content", vlaues); // onOk && onOk(vlaues.areaData ? vlaues.areaData : []); }} > {(fields, { add, remove }) => { return ( <> {fields.map((field) => ( remove(field.name)}> 删除 } title="自定义区域内容" > {({ getFieldValue, setFieldsValue }) => { return ( getFieldValue(["areaData", field.name, "type"]) && ( ) ); }} ))} ); }}
); }

你可能感兴趣的:(javascript,reactjs,ant)