【发布时间】:2017-11-17 22:01:10
【问题描述】:
我很难将数据子项映射到表。您在下面的 json 数据中看到的是一个项目的示例。我在卡片组件中有一个地图(请参阅渲染功能内容),以显示我在 MaterialUI 卡片中独立拥有的项目。每张牌也有一张桌子。我正在将表格内容与每个项目中的子项(行)进行映射。因为不是每个项目都有相同数量的数据或相同的数据。
图片、页面和部分都很好地填充了我的卡片。但是我的行内容没有填充到表格行(TableRowColumn)中
这是一个简化的json:
exports.administration = [
{
id:'1',
image: '/assets/images/media/christopher-walken.jpg',
page: '',
section: 'Test one',
rows: [
{
id:'1.1',
type: 'STRING',
name: 'Page1Var1',
description:'n/a',
show:'Both',
label: 'Page1Var1',
value: 'Test one',
presentation: 'n/a',
lines: '1',
characters: '4096',
},
],
},
]
数据库声明和调用
const TEMPLATEITEMS = require('data/templates.js');
const administrationData = TEMPLATEITEMS['administration'];
在我的渲染函数中:
{administrationData.map((row, index) => (
<Card key={index}>
<CardText>
<div>
//these are working fine
<h4>{row.page} / {row.section}</h4>
<img src={row.image} alt={row.name} />
</div>
<Table>
<TableBody>
//these are not working. I tried several variations as you see below
<TableRow id={row.rows.id}>
<TableRowColumn> {row.type} </TableRowColumn>
<TableRowColumn> {row[index].rows.name} </TableRowColumn>
...
<TableRowColumn> {rows.characters} </TableRowColumn>
</TableRow>
</TableBody>
</Table>
</CardText>
</Card>
))}
提前谢谢你们!
【问题讨论】: