ant design表格render函数中text和record参数的区别?

函数说明
renderfunction(text, record, index)生成复杂数据的渲染函数,参数分别为当前行的值,当前行数据,行索引,

text和record分别是什么?为什么我打印出来的结果一样?

阅读 221
评论
    1 个回答

    给你举个例子:

    import React from "react";
    import ReactDOM from "react-dom";
    import "antd/dist/antd.css";
    import "./index.css";
    import { Table } from "antd";
    const columns = [
      {
        title: "Name",
        dataIndex: "name",
        render: (text, row, index) => {
          console.log(text, row);
          if (index < 4) {
            return <a>{text}</a>;
          }
          return {
            children: <a>{text}</a>,
            props: {
              colSpan: 5
            }
          };
        }
      },
    ];
    
    const data = [
      {
        key: "1",
        name: "John Brown",
        age: 32,
        tel: "0571-22098909",
        phone: 18889898989,
        address: "New York No. 1 Lake Park"
      }
    ];
    
    ReactDOM.render(
      <Table columns={columns} dataSource={data} bordered />,
      document.getElementById("container")
    );

    上面代码中对应的text为John Brown;而 record为{key: "1",name: "John Brown",age: 32,tel: "0571-22098909",phone: 18889898989,address: "New York No. 1 Lake Park"}

    如果你说两个一样,就得看你的代码是怎么写的了

      撰写回答

      登录后参与交流、获取后续更新提醒

      相似问题
      推荐文章