React Scroll Spy库(organism-react-scroll-nav)npm软件包

时间:2018-10-17 08:26:11

标签: javascript reactjs react-navigation

有人使用过React Scroll Spy Library(organism-react-scroll-nav)organism-react-scroll-nav

如何使用ScrollReceiver,scrollDispatch?谁能帮忙吗?

1 个答案:

答案 0 :(得分:0)

Jony,您可以使用“ react scrollspy nav”代替上面的软件包。它具有功能有限的最少设置。您可以使Navbar完全自定义。

LINK: https://www.npmjs.com/package/react-scrollspy-nav

工作示例: http://learningdemo.galaxyweblinks.com/alok-mali/react-demo/react-bootstrap/

我的代码

<ScrollspyNav
    scrollTargetIds={[
      "home-section",
      "about-section",
      "services-section",
      "portfolio-section",
      "pricing-section",
      "contact-section"
    ]}
    activeNavClass="active"
  >
    <Navbar bg="dark" variant="dark" expand="lg" fixed="top">
      <Navbar.Brand>React-Bootstrap</Navbar.Brand>
      <Navbar.Toggle aria-controls="basic-navbar-nav" />
      <Navbar.Collapse id="basic-navbar-nav">
        <Nav className="mr-auto">
          <Nav.Link href="#home-section">HOME</Nav.Link>
          <Nav.Link href="#about-section">ABOUT</Nav.Link>
          <Nav.Link href="#services-section">SERVICES</Nav.Link>
          <Nav.Link href="#portfolio-section">PORTFOLIO</Nav.Link>
          <Nav.Link href="#pricing-section">PRICING</Nav.Link>
          <Nav.Link href="#contact-section">CONTACT</Nav.Link>
        </Nav>
      </Navbar.Collapse>
    </Navbar>
  </ScrollspyNav>

其中home-section,about-section等是我的部分的ID。