【问题标题】:How to conditionally color specific rows in an AntD table如何有条件地为 AntD 表中的特定行着色
【发布时间】:2020-03-02 06:08:54
【问题描述】:

我正在尝试根据来自表数据源的一些数据为整行着色。

我看到你可以使用rowClassName,但不太明白它是如何工作的。

希望有一些打字稿示例!谢谢!

<Table
  columns={cols}
  dataSource={data}
  rowKey={(record: obj) => record.key}
  rowClassName={(record: obj) => record.amount == '0' ? <???> : ''}
/>

【问题讨论】:

    标签: reactjs typescript antd ant-design-pro


    【解决方案1】:

    这是我们代码库中的一个示例:

    import s from './styles.css'
    
    useStyles(s)
    ...
     rowClassName={(_r, i) => (i % 2 ? s.odd : s.even)}
    

    在一个 css 文件中:

    
    .odd {
      background: color(var(--midnight-5) alpha(50%));
    }
    
    .even {
      background-color: #f8f9fa;
    }
    

    我们使用Isomorphic style loader

    【讨论】:

    • useStyles 与 antd?这是什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 2015-06-11
    • 1970-01-01
    • 2017-12-04
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多