zoukankan      html  css  js  c++  java
  • Antd表格跨行

    • 组件
     <Table columns={columns} dataSource={data} bordered />
    
    • columns(关键)

    在需要合并的行的columns种,设置rowSpan

    rowSpan值为0时,不渲染表格。

    const columns = [
        {
            title: 'Name',
            dataIndex: 'name',
        },
        {
            title: 'Home phone',
            colSpan: 2,
            dataIndex: 'tel',
            render: (value, row, index) => {
                const obj = {
                    children: value,
                    props: {},
                };
                // rowSpan行 从index开始合并3行,值为第一个值
                if (index === 0) {
                    obj.props.rowSpan = 3;
                }
                // 从index+1开始,设置rowSpan=0,不渲染表格
                if (index === 1 || index === 2) {
                    obj.props.rowSpan = 0;
                }
                return obj;
            },
        },
    ];
    
    • data
    const data = [
        {
            key: '1',
            name: 'John Brown',
            tel: 'test1',
        },
        {
            key: '2',
            name: 'Jim Green',
            tel: '0571-22098333',
        },
        {
            key: '3',
            name: 'Joe Black',
            tel: '0575-22098909',
        },
        {
            key: '4',
            name: 'Jim Red',
            tel: '0575-22098909',
        },
    ];
    
  • 相关阅读:
    ajax小白理解
    Once more
    win滚动条样式修改
    NOIP2018游记
    Stirling数笔记
    【Start From Here】HNOI2018 滚粗记
    6面相对象
    5方法定义及调用
    Java4数组
    Java3流程控制语句
  • 原文地址:https://www.cnblogs.com/wattmelon/p/14281284.html
Copyright © 2011-2022 走看看