每个列表项

时间:2017-03-08 21:55:56

标签: javascript reactjs

我列出了几个项目。每个项目都包含服务信息和按钮。

Image 1

每个投标包含我想在点击后获得的id和其他道具

Image 2

如何在点击按钮后获得特定的项目属性?

UPD:

export default class ListFresh extends React.Component {
  constructor(props) {
    super(props);
    this.state = { tenders: [] };
  }

  componentDidMount() {
    elastic.search().catch(e => alert(e)).then(
      data => this.setState({tenders: data.items})
    );
  }

  render() {
    return (
      <TenderList tenders={this.state.tenders}/>
    );
  }
}

class TenderList extends React.Component {
  render() {
    return (
       <div className="tender-list">
          <List items={this.props.tenders}/>
       </div>
    );
  }
}

产生温柔

export default class List extends React.Component {
  constructor(props) {
    super(props);
    this.state = { nodes: [] };
  }

  render () {
    const data = this.props.items;
    var node;
    data.map(item => (
      console.log(item),
        node = {
            headerName : item._source.tender.title,
            isOpened: false,
            isReactComponent: true,
            items : [
              <Tender tender={item._source} id={item._id}/>
            ],
            height: 250
          },
      DATALIST.push(node)
    ));

    return (
      <div id="admin-menu">
        <ReactExpandableListView
          data={DATALIST}
          headerAttName="headerName"
          itemsAttName="items"
        />
      </div>
    )
  }
}

0 个答案:

没有答案