运行结果:
表格组件 TableList.js
import {
Table, Space, Button } from "antd";
import {
Component } from "react";
const tableList = [
{
key: "1",
name: "胡彦斌",
age: 32,
sex: "0",
address: "西湖区湖底公园1号",
like: ["唱歌", "跳舞"]
},
{
key: "2",
name: "胡彦祖",
age: 42,
sex: "0",
address: "西湖区湖底公园1号",
like: ["跳舞"]
}
];
export default class TableList extends Component {
constructor(props) {
super(props);
this.state = {
visible: false, // 控制弹窗的显隐
editData: {
} // 弹窗的数据
};
}
getColumns() {
let self = this;
return [
{
title: "姓名",
dataIndex: "name",
key: "name"
},
{
title: "年龄",
dataIndex: "age",
key: "age"
},
{
title: "住址",
dataIndex: "address",
key