Antd 表格行可以使用 Tooltip 组件来实现提示框,下面是一个示例代码:
import React from 'react';
import { Table, Tooltip } from 'antd';
const columns = [
{
title: '姓名',
dataIndex: 'name',
key: 'name',
render: (text) => (
{text}
),
},
{
title: '年龄',
dataIndex: 'age',
key: 'age',
render: (text) => (
{text}
),
},
{
title: '地址',
dataIndex: 'address',
key: 'address',
render: (text) => (
{text}
),
},
];
const data = [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
},
];
const TableWithTooltip = () => {
return (
);
};
export default TableWithTooltip;
在此示例中,我们通过在列的 render
函数中包含 Tooltip
组件来为表格行添加提示框。每个 Tooltip
组件都有一个 title
属性,用于指定在鼠标悬停在行上时显示的提示内容。对于需要添加提示框的列,我们只需要将其 render
函数中的文本包装在 Tooltip
组件中即可。