Javascript 如何打印React组件中的行和列
我正在使用React with React Boostrap,我正在尝试找出如何将三张牌放在三列上,并在每次达到三张牌时添加一行新行。我似乎不明白如何打印一个新的行标记。据我所知,我不能以一种好的方式将条件包装在and标记周围。我怎样才能做到这一点Javascript 如何打印React组件中的行和列,javascript,reactjs,Javascript,Reactjs,我正在使用React with React Boostrap,我正在尝试找出如何将三张牌放在三列上,并在每次达到三张牌时添加一行新行。我似乎不明白如何打印一个新的行标记。据我所知,我不能以一种好的方式将条件包装在and标记周围。我怎样才能做到这一点 {items && items.map((item, index) => <Row>
{items &&
items.map((item, index) =>
<Row>
<Col>
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src={item.logo}/>
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card title and make up the bulk of
the card's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
</Col>
</Row>
)
}
{items&&
items.map((项目,索引)=>
卡片标题
一些快速的示例文本构建在卡片标题上,并构成大部分
卡片的内容。
去某处
)
}
使用显示:'grid'
和gridTemplateColumns:'1fr 1fr 1fr'
可以更快、更干净地完成此操作
您必须将父级的显示设置为网格
,并将网格模板列
设置为1fr 1fr
,您将有一个表,每个表包含父级的一部分
您的代码如下所示:
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr' }} >
{items && items.map((item, index) =>
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src={item.logo} />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card title and make up the bulk of
the card's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
)}
</div>
{items&&items.map((项目,索引)=>
卡片标题
一些快速的示例文本构建在卡片标题上,并构成大部分
卡片的内容。
去某处
)}
更多关于网格的信息 使用显示:'grid'
和gridTemplateColumns:'1fr 1fr 1fr'
可以更快、更清晰地完成此操作
您必须将父级的显示设置为网格
,并将网格模板列
设置为1fr 1fr
,您将有一个表,每个表包含父级的一部分
您的代码如下所示:
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr' }} >
{items && items.map((item, index) =>
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src={item.logo} />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card title and make up the bulk of
the card's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
)}
</div>
{items&&items.map((项目,索引)=>
卡片标题
一些快速的示例文本构建在卡片标题上,并构成大部分
卡片的内容。
去某处
)}
更多关于网格的信息 您可以使用引导网格执行类似操作
通过在每行中放置3列,引导网格将在第三列之后的每个新列中打断该列
{项目&&
items.map((项目,索引)=>
//12/4=每行3列
卡片标题
一些在卡片标题上构建的快速示例文本
并且构成了卡片内容的大部分。
去某处
)
}
您可以使用引导网格执行类似操作
通过在每行中放置3列,引导网格将在第三列之后的每个新列中打断该列
{项目&&
items.map((项目,索引)=>
//12/4=每行3列
卡片标题
一些在卡片标题上构建的快速示例文本
并且构成了卡片内容的大部分。
去某处
)
}