reactjs React Bootstrap 导航栏未显示

1mrurvl1  于 2023-01-12  发布在  React
关注(0)|答案(2)|浏览(151)

我正在尝试使用React引导导航栏组件。然而,安装 Bootstrap 并粘贴示例代码后,导航栏似乎无法加载。我似乎无法理解这是如何不起作用的。任何帮助将不胜感激!我的app.js代码如下:

import 'regenerator-runtime/runtime';
import React from 'react';
import './assets/global.css';
import { Container, Nav, Navbar, NavDropdown} from 'react-bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';

export default function App() {
  return (
    <Navbar collapseOnSelect expand="lg" bg="dark" variant="dark">
      <Container>
        <Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
        <Navbar.Toggle aria-controls="responsive-navbar-nav" />
        <Navbar.Collapse id="responsive-navbar-nav">
          <Nav className="me-auto">
            <Nav.Link href="#features">Features</Nav.Link>
            <Nav.Link href="#pricing">Pricing</Nav.Link>
            <NavDropdown title="Dropdown" id="collasible-nav-dropdown">
              <NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
              <NavDropdown.Item href="#action/3.2">
                Another action
              </NavDropdown.Item>
              <NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
              <NavDropdown.Divider />
              <NavDropdown.Item href="#action/3.4">
                Separated link
              </NavDropdown.Item>
            </NavDropdown>
          </Nav>
          <Nav>
            <Nav.Link href="#deets">More deets</Nav.Link>
            <Nav.Link eventKey={2} href="#memes">
              Dank memes
            </Nav.Link>
          </Nav>
        </Navbar.Collapse>
      </Container>
    </Navbar>,
  );
}

global.css

body {
  margin: 0;
}
92dk7w1h

92dk7w1h1#

问题可能是您在安装一些react-bootstrap时没有修复它们。调用npm audit fix --force并查看它是否工作

piah890a

piah890a2#

我的错误是我安装了react-bootstrap在这错误的文件夹. always check your directory guys!

相关问题