反应和引导最佳实践(我应该如何设计我的网站)

发布于 2025-02-07 13:14:12 字数 116 浏览 2 评论 0原文

我正在React创建我的第一个网站。我想使用Bootstrap的网格系统,但是我真的不知道何时应该使用它或更广泛。

网格系统在app.js和每个组件等地方是否最好?只是在每个组件中?只是在app.js中?

I am making my first ever website in React. I want to use Bootstrap's grid system, but I don't really know when I should use this or rather how extensively.

Is the grid system best in places like App.js and in each individual component? Just in each individual component? Just in App.js?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丶情人眼里出诗心の 2025-02-14 13:14:12

我使用React-bootstrap。我发现与之相处非常简单,而您在VS代码中获得的Intellisense很棒。

首先,仅:

npm install react-bootstrap

您可以看到所有组件的列表在这里

然后,您只需将要使用的组件添加到导入中即可。

import {
  Navbar,
  Container,
  Nav,
  NavbarBrand,
  Row,
  Col,
  {...}
} from "react-bootstrap";

然后在您的渲染输出中,例如:

return (
      <Container>
        <Navbar>
          <NavbarBrand>Brand</NavbarBrand>
          <Navbar.Collapse>
            <Nav>
              <NavItem>Item 1</NavItem>
            </Nav>
          </Navbar.Collapse>
        </Navbar>
        <Row>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
        </Row>
      </Container>
    );

I use React-Bootstrap. I've found it very simple to get going with, and the intellisense you get in VS Code is great.

To get started, just:

npm install react-bootstrap

You can see a list of all of the components here.

Then you just add the components that you want to use to your import.

import {
  Navbar,
  Container,
  Nav,
  NavbarBrand,
  Row,
  Col,
  {...}
} from "react-bootstrap";

Then in your rendered output, for example:

return (
      <Container>
        <Navbar>
          <NavbarBrand>Brand</NavbarBrand>
          <Navbar.Collapse>
            <Nav>
              <NavItem>Item 1</NavItem>
            </Nav>
          </Navbar.Collapse>
        </Navbar>
        <Row>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
          <Col md={4}>
          </Col>
        </Row>
      </Container>
    );

方圜几里 2025-02-14 13:14:12

我们可以使用普通的引导程序来使用网格系统。我们必须根据要做的要求在大多数组件中使用它是响应迅速的。

简单选择:
还有其他选项可以使用bootstrap内部的bootstrap,例如组件库。您可以使用 react-bootstrap 。这些库提供了组件,您可以通过这些组件轻松地创建带有引导程序的React和功能的网站。

We can use plain bootstrap to use grid system. We have to use it inside most of the component according to the requirement to make is responsive.

Easy Option:
There are other options to use bootstrap inside react like component libraries. You can use either Reactstrap or React-Bootstrap. These libraries provide components by which you can easily create website with react and power of bootstrap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文