我按照 React-Bootstrap 文档,尤其是这段代码来制作我的导航栏 -> https://react-bootstrap.github.io/components/navbar/#navbars-mobile-friendly
但是,我从谷歌浏览器清除了我的应用程序会话,我的导航栏似乎保持折叠状态。
我在互联网上搜索没有成功,因为我不确定问题是什么以及它来自哪里?
有我<Navbar/>
的代码
import React from 'react'
import {
Navbar as BoostrapNavBar,
Nav,
NavItem,
MenuItem,
NavDropdown } from 'react-bootstrap';
import { Link } from 'react-router-dom';
export default class Navbar extends React.Component {
render () {
return (
<BoostrapNavBar inverse collapseOnSelect>
<BoostrapNavBar.Header>
<BoostrapNavBar.Brand>
<a href="/">{this.props.navbar_title}</a>
</BoostrapNavBar.Brand>
<BoostrapNavBar.Toggle />
</BoostrapNavBar.Header>
<BoostrapNavBar.Collapse>
<Nav pullRight>
<NavItem componentClass={Link} href="/collections" to="/collections">Collections</NavItem>
<NavItem componentClass={Link} href="/bracelets" to="/bracelets">Bracelets</NavItem>
<NavItem componentClass={Link} href="/glasses" to="/glasses">Lunettes</NavItem>
<NavItem componentClass={Link} href="/watches" to="/watches">Montres</NavItem>
<NavDropdown eventKey={3} title="Support" id="basic-nav-dropdown">
<MenuItem componentClass={Link} href="/support" to="/support">Messages</MenuItem>
<MenuItem componentClass={Link} href="/new_message" to="/new_message">Contacter le Support</MenuItem>
</NavDropdown>
<NavItem componentClass={Link} href="/login" to="/login"><img src={'../resources/images/user.png'} alt="User"/></NavItem>
<NavItem componentClass={Link} href="/shopping_bag" to="/shopping_bag"><img src={'../resources/images/shopping-bag.png'} alt="Shopping-Bag"/></NavItem>
</Nav>
</BoostrapNavBar.Collapse>
</BoostrapNavBar>
);
}
}
欢迎任何帮助!
基于评论:
<div id="root">
<div>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header"><a href="/" class="navbar-brand">ShopField</a><button type="button" class="navbar-toggle collapsed"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button></div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li role="presentation" class=""><a href="/collections">Collections</a></li>
<li role="presentation" class=""><a href="/bracelets">Bracelets</a></li>
<li role="presentation" class=""><a href="/glasses">Lunettes</a></li>
<li role="presentation" class=""><a href="/watches">Montres</a></li>
<li class="dropdown">
<a id="basic-nav-dropdown" role="button" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false" href="#">Support <span class="caret"></span></a>
<ul role="menu" class="dropdown-menu" aria-labelledby="basic-nav-dropdown">
<li role="presentation" class=""><a href="/support" role="menuitem" tabindex="-1">Messages</a></li>
<li role="presentation" class=""><a href="/new_message" role="menuitem" tabindex="-1">Contacter le Support</a></li>
</ul>
</li>
<li role="presentation" class=""><a href="/login"><img src="../resources/images/user.png" alt="User"></a></li>
<li role="presentation" class=""><a href="/shopping_bag"><img src="../resources/images/shopping-bag.png" alt="Shopping-Bag"></a></li>
</ul>
</div>
</div>
</nav>
<div>Home Page</div>
</div>
</div>