要将Table包装为Form.List,您可以按照以下步骤进行操作:
import { Form, Table, Input, Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { useForm } from 'antd/lib/form/Form';
const TableForm = () => {
const [form] = useForm();
const [dataSource, setDataSource] = useState([]);
const columns = [
{
title: '列1',
dataIndex: 'column1',
key: 'column1',
render: (text, record, index) => (
),
},
{
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text, record, index) =>
dataSource.length >= 1 ? (
) : null,
},
];
const handleDelete = (index) => {
const newDataSource = [...dataSource];
newDataSource.splice(index, 1);
setDataSource(newDataSource);
};
const handleAdd = () => {
const newData = {
column1: '',
};
setDataSource([...dataSource, newData]);
};
return (
{(fields, { add, remove }) => (
<>
{fields.map((field, index) => (
record.key}
dataSource={dataSource}
columns={columns}
pagination={false}
/>
))}
>
)}
);
};
- 在父组件中使用TableForm组件:
const ParentComponent = () => {
return (
);
};
通过以上步骤,您就可以将Table包装为Form.List,并实现动态添加和删除行的功能。
相关内容
热门资讯
科普透视!wepoker作弊方...
科普透视!wepoker作弊方法,微信小程序微乐房间有技巧吗,绝活教程(了解有挂)-哔哩哔哩1、不需...
关于透视!拱趴大菠萝十三水作弊...
关于透视!拱趴大菠萝十三水作弊,微乐自建房辅助多少钱一个月,机巧教程(了解有挂)-哔哩哔哩1、首先打...
详情透视!wepoker怎么拿...
详情透视!wepoker怎么拿到好牌,微乐广西麻辣,练习教程(有挂方针)-哔哩哔哩1、wepoker...
揭露透视!哈糖大菠萝破解器,微...
揭露透视!哈糖大菠萝破解器,微信卡五星小程序辅助,攻略教程(今日头条)-哔哩哔哩哈糖大菠萝破解器脚本...
辅助透视!德普之星透视软件免费...
辅助透视!德普之星透视软件免费入口官网,微乐河南小程序辅助器免费,讲义教程(新版有挂)-哔哩哔哩1、...
曝光透视!uupoker透视,...
曝光透视!uupoker透视,微信小程序微乐辅助器教程,操作教程(有挂方式)-哔哩哔哩1、不需要AI...
解迷透视!pokemmo手机脚...
解迷透视!pokemmo手机脚本,微乐自建房免费黑科技下载,妙招教程(真的有挂)-哔哩哔哩1、pok...
解迷透视!德州透视竞技联盟,微...
解迷透视!德州透视竞技联盟,微信小程序 微乐陕西挖坑 外挂,要领教程(有挂方法)-哔哩哔哩1、德州透...
解谜透视!wepoker辅助器...
解谜透视!wepoker辅助器下载,广西微乐小程序辅助器,技法教程(有挂教程)-哔哩哔哩1、wepo...
详情透视!哈糖大菠萝攻略,微乐...
详情透视!哈糖大菠萝攻略,微乐自建房怎么提高运气,机巧教程(有挂分享)-哔哩哔哩1、点击下载安装,哈...