繁体   English   中英

如何更改react-table中单行的边框颜色

[英]How to change the border color of a single row in react-table

我知道如何更改ReactTable object 中一行的背景颜色(代码如下)。

如何更改行边框的颜色(不是整个表格的边框)? 我尝试将以下代码中的background替换为border-colorborderColorborder ,但这些选项都不起作用——或者,我得到一个错误,或者在编译时什么也没有发生。

getTrProps={(state, rowInfo, column) => {
    if(rowInfo) {
        return {
            style: {
                background: "blue"
            }
        };
    }
    return {}; 
}

像这样:

getTrProps = (state, rowInfo, instance) => {
    if (rowInfo) {
      return {
        style: {
          border: rowInfo
            ? rowInfo.row.age >= 20
              ? "solid 1px black"
              : "none"
            : "none"
        }
      };
    }
    return {};
  };

工作示例: https://codesandbox.io/s/react-table-gettrprops-ijgzy

按照此操作根据 row.value 条件更改单个单元格颜色

{
  Header: () => <div className="text-center font-weight-bold">Status</div>,
  accessor: "selectedstatus",
  className: "font",
  width: 140,
  Cell: (row) => (
    <div
      className="text-center h-6"
      style={{ background: row.value === "Selected" ? "green" : "red" }}
    >
      {row.value}
    </div>
  ),
},

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM