import { Table } from "antd";
import React from "react";
export class Tables extends React.Component {
constructor(props) {
super(props);
}
render() {
const columns = [
{
title: '姓名',
dataIndex: 'name',
align: 'center',
},
{
title: '电话',
dataIndex: 'tel',
align: 'center',
},
{
title: '地址',
dataIndex: 'address',
align: 'center',
},
{
title: '邮箱',
dataIndex: 'email',
align: 'center',
render: (text,r) => <a href={"www.baidu.com"+r.key} target="_blank">{text}</a>,
},
];
const data = [
{
key: '1',
name: 'John Brown',
tel: '10086',
address: '成都',
email: '103685334@qq.com',
},
{
key: '2',
name: 'Jim Green',
tel: '1008611',
address: '上海',
email: '',
},
{
key: '3',
name: 'Joe Black',
tel: '10001',
address: '深圳',
email: '',
},
];
return (
<Table
columns={columns}
dataSource={data}
bordered
/>
)
}
}
可以用reqwest模块加载接口数据后调用this.setState更新状态数据。或者直接用原生的fetch对象获取数据也行,题主这个问题和下面这个差不多。data改为异步获取就行
approvalDTO.applyTime/ approvalDTO.approvalId/ approvalDTO.applyInterfaceName新增到table中,columns对象得新增这3个字段。还有接口返回的格式是什么,最好贴出来看下,键名称是approvalDTO.applyTime/ approvalDTO.approvalId/ approvalDTO.applyInterfaceName 这样?
接口是复用的,只是新增字段(approvalDTO.applyTime/ approvalDTO.approvalId/ approvalDTO.applyInterfaceName),希望用antd的远程数据加载实现。谢谢