Tables 变量是一个包含对象数组的对象
const Tables = {QD1:[{key:value, key:value, key:value, key:value}],QD1:[{key:value, key:value, key:value,key:value}]}
我正在尝试根据它的内容构建一个表。但是,当我运行以下代码时,当我期望为数组中的每个对象获取一行时,我只得到一行。谁能告诉我我做错了什么?
render() {
const Tables = this.state.tableResult.Tables;
console.log(Tables);
if(typeof Tables !== 'undefined'){
const display = Object.keys(Tables).map((bannerRowKey, bannerRowIndex) => {
let crossTab = Object.values(Tables[bannerRowKey]);
console.log(crossTab);
// if(bannerRowIndex===0){
const TableRow = crossTab.map((crossTabRow,crossTabRowIndex) => (
// console.log(crossTabRowIndex);
<tr key={'header'+crossTabRowIndex.toString()}></tr>
));
return (
<thead key={'header'+bannerRowIndex.toString()}>{TableRow}</thead>
)
})
return <div id="table_holder" className="table-responsive mx-3">
<table className="table-sm">
{display}
</table>
</div>
}else{
return (
<div id="table_holder" className="table-responsive mx-3">
<table className="table-sm">
</table>
</div>
);
}
}