【问题标题】:Composing material table from custom rows从自定义行组成材料表
【发布时间】:2016-09-16 19:14:32
【问题描述】:

我想用专用组件将表格中的每一行包装起来,使其具有类似的结构

<TableBody>
  <MyRow/>
  <MyRow/>
</TableBody>

而不是

<TableBody>
  <TableRow/>
  <TableRow/>
</TableBody>

但是,在这样做之后,选择复选框消失了。

https://jsfiddle.net/uLed8p5u/

有什么建议可以解决吗?

【问题讨论】:

标签: reactjs material-ui


【解决方案1】:
var MyRow = React.createClass({
    render: function () {
        return <TableRow {...this.props}>
        {this.props.children[0]}
        <TableRowColumn>2</TableRowColumn>
        <TableRowColumn>Randal White</TableRowColumn>
        <TableRowColumn>Unemployed</TableRowColumn>
      </TableRow>
      }
});

只需要以与 TableBody 组件相同的方式将 props 重新应用于子元素即可。

【讨论】:

    猜你喜欢
    • 2019-04-28
    • 1970-01-01
    • 1970-01-01
    • 2019-09-11
    • 1970-01-01
    • 2020-12-13
    • 2017-04-06
    • 2020-05-07
    • 2020-09-02
    相关资源
    最近更新 更多