这是我在实现 react-bootstrap-table 之前的 React 类(它可以工作,它会打印它应该打印的内容):
class ResultItem extends ComponentBase {
constructor(props) {
super(props);
this.state = {
key: null,
description: '',
start_date: '',
end_date: '',
vendor_name: {},
buyer_name: {},
preview_file: '',
};
}
render() {
const data = this.props;
return (
<div>
{data.title}
{data.description}
{data.start_date}
{data.end_date}
{data.vendor_name}
{data.buyer_name}
</div>
);
}
}
我想在 react-bootstrap-table 中显示这些信息。这是我尝试的实现,如下所示。表格上说没有要显示的数据,所以我一定没有正确连接到信息。
class ResultItem extends ComponentBase {
constructor(props) {
super(props);
this.state = {
key: null,
description: '',
start_date: '',
end_date: '',
vendor_name: {},
buyer_name: {},
preview_file: '',
};
}
render() {
const data = this.props;
return (
<BootstrapTable data={this.props.data}>
<TableHeaderColumn dataField="title" isKey={true}>Title</TableHeaderColumn>
<TableHeaderColumn dataField="start_date">Start Date</TableHeaderColumn>
<TableHeaderColumn dataField="end_date">End Date</TableHeaderColumn>
<TableHeaderColumn dataField="vendor_name">Vendor</TableHeaderColumn>
<TableHeaderColumn dataField="buyer_name">Buyer</TableHeaderColumn>
</BootstrapTable>
);
}
}