【发布时间】:2019-05-10 10:14:36
【问题描述】:
我想每行显示 4 个项目。我有一个如下标记。根据该标记,我需要显示四个 单行中的项目。例如,如果我有 8 个数据,那么将有两行,每行包含 4 项。
如果我在<Grid gutters col="cols-4"> 之外循环,那么将有八个这样的元素,如果我循环
在该元素内将有八个 Cell 元素。这种情况如何处理?
这是标记
const data = [
{id: 1, header: 'header', content: 'content', footer: 'footer'},
{id: 2, header: 'header', content: 'content', footer: 'footer'},
{id: 3, header: 'header', content: 'content', footer: 'footer'},
{id: 4, header: 'header', content: 'content', footer: 'footer'},
{id: 5, header: 'header', content: 'content', footer: 'footer'},
{id: 6, head/xer: 'header', content: 'content', footer: 'footer'},
{id: 7, header: 'header', content: 'content', footer: 'footer'},
{id: 8, header: 'header', content: 'content', footer: 'footer'},
]
<Grid gutters col="cols-4">
<Grid.Cell key={datum.id}>
<Card>
<Card.Header>{datum.header}</Card.Header>
<Card.Content>{datum.content}</Card.Content>
<Card.Footer>{datum.footer}</Card.Footer>
</Card>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
</Grid>
<Grid gutters col="cols-4">
<Grid.Cell key={datum.id}>
<Card>
<Card.Header>{datum.header}</Card.Header>
<Card.Content>{datum.content}</Card.Content>
<Card.Footer>{datum.footer}</Card.Footer>
</Card>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
<Grid.Cell>
</Grid.Cell>
</Grid>
【问题讨论】:
标签: javascript reactjs