我是新手,我想立即与React-Bootstrap库一起使用它。现在,我不确定如何集成语义元素,例如标题,部分等,并在同一时间使用容器,行和Col组件。

问题描述 投票:0回答:1
现在使用React-Bootstrap库,我想我会做类似的事情:

<Container className="main-header"> <Row> <Col sm={6}> Some content here </Col> </Row> </Container>

我没有深入研究抽象,但我的猜测是这些组件都将成为div元素。
我应该将整个内容嵌套到一个额外的语义HTML元素中吗?还是还有另一种传统的方法?

您正在寻找

as

属性:

https://reaect-bootstrap.netlify.app/docs/getting-started/introduction#as-prop-api

因此,您的代码变为:
react-bootstrap semantic-markup
1个回答
0
投票
<Container as="header" className="main-header"> <Row> <Col sm={6}> Some content here </Col> </Row> </Container>

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.