基础表格
表格两大部分
第一个部分是列 columns 列头
第二个部分是 data 数据
基础使用指南
import React, { useState } from 'react'
import { Table } from 'antd'
function useBasicTable1() {
const [pagnationPage] = useState('bottomCenter') //改成BottomCenter
//列数据
const columns = [
{
title: '姓名',
width: 100, //不写就自适应
dataIndex: 'name', //列对应的数据名称
render: (text) => <div>{text}</div>,
},
{
title: '资产',
width: 100, //不写就自适应
className: 'column-money',
dataIndex: 'money', //列对应的数据名称
align: 'center', //right center,left
},
{
title: '地址',
dataIndex: 'address', //列对应的数据名称
},
]
//数据
const data = [
{
key: '1',
name: '张三',
money: '$300,000.00',
address: 'New York No. 1 Lake Park',
},
{
key: '2',
name: '李四',
money: '$1,256,000.00',
address: 'London No. 1 Lake Park',
},
{
key: '3',
name: '王五',
money: '$120,000.00',
address: 'Sidney No. 1 Lake Park',
},
]
//Header
const HeaderData = () => {
return <div classsname="Footer">这就是头部222</div>
}
//Footer
const FooterData = () => {
return <div classsname="Footer">这就是尾巴</div>
}
//分页
const handleClick = (current, pageSize) => {
console.log(current, pageSize)
console.log(`当前页是${current}`)
console.log(`每页条数${pageSize}`)
}
return (
<Table
columns={columns}
dataSource={data}
bordered
title={HeaderData}
footer={FooterData}
pagination={{
position: [pagnationPage],
defaultCurrent: 1,
defaultPageSize: 2,
total: 50,
onChange: handleClick,
}}
/>
)
}
export default useBasicTable1