我正在尝试为我的反应应用程序制作导航栏,并且我正在使用以下代码: ReactStrap navbar component
但是,导航栏图标不会出现在小型设备视图中。
我的导航栏.js
import React, {Component} from 'react';
import NavItems from "./NavItems";
import { Collapse, Navbar, NavbarToggler, NavbarBrand, Nav, NavItem, NavLink } from 'reactstrap';
class NavBar extends Component {
constructor(props) {
super(props);
this.toggleNavbar = this.toggleNavbar.bind(this);
this.state = {
collapsed: true
};
}
toggleNavbar() {
this.setState({
collapsed: !this.state.collapsed
});
}
render() {
return (
<div>
<Navbar color="faded" light>
<NavbarBrand href="/" className="mr-auto">Hoje para jantar</NavbarBrand>
<NavbarToggler onClick={this.toggleNavbar} className="mr-2" />
<Collapse isOpen={!this.state.collapsed} navbar>
<Nav navbar>
<NavItems>
<NavLink href="/components/">Components</NavLink>
</NavItems>
</Nav>
</Collapse>
</Navbar>
</div>
);
}
}
export default NavBar;