我列出了几个项目。每个项目都包含服务信息和按钮。
每个投标包含我想在点击后获得的id和其他道具
如何在点击按钮后获得特定的项目属性?
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>
)
}
}