javascript - React-Bootstrap - 如何保持 Navbar.Toggle 按钮始终可见?

标签 javascript reactjs navbar react-bootstrap

我正在使用 React-Bootstrap 制作导航菜单。展开后的切换按钮包含我的导航项,用于转到应用程序的不同部分。到目前为止,我知道它应该响应小屏幕设备,因为一旦显示宽度小于 768px,导航项就会消失在切换按钮内,如果屏幕更宽,导航项就会出现在导航栏内。

我想要的是始终将切换按钮、其行为及其导航项(来自 Navbar.Collapse)保留在内部。我搜索了文档和其他问题,但没有找到任何方法来做到这一点。

这是我的代码:

    import React from 'react';
    import { bindActionCreators } from 'redux';
    import { connect } from 'react-redux';
    import { Glyphicon, Nav, Navbar, NavItem } from 'react-bootstrap';
    import { actionCreators } from '../store/ExpeditionStore';
    import './NavMenu.css';
    const translations = require('../Translations');

    class NavMenu extends React.Component {

    render() {
        return (
            <Navbar inverse fixedTop fluid collapseOnSelect>

                <Navbar.Header>
                    <Navbar.Toggle />
                    <Navbar.Brand>
                        {this.props.title}
                    </Navbar.Brand>
                </Navbar.Header>

                <Navbar.Collapse>
                    <Nav>
                        <NavItem>
                            <Glyphicon glyph='plane' />{translations.getCaption('shipment')}
                        </NavItem>
                    </Nav>
                    <Nav>
                        <NavItem onClick={() => this.props.switchLanguage(translations)}>
                            EN/FR
                        </NavItem>
                    </Nav>
                </Navbar.Collapse>
            </Navbar>
        );
    }
}

export default connect(
    state => state.expeditionStore,
    dispatch => bindActionCreators(actionCreators, dispatch)
)(NavMenu);

即使设备宽度超过 768 像素,如何将切换按钮和 Navbar.Collapse 导航项保留在其中?

最佳答案

将值为“xl”或“xxl”的展开属性添加到主导航栏标记。例如:展开=“xxl”

关于javascript - React-Bootstrap - 如何保持 Navbar.Toggle 按钮始终可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51365291/

相关文章:

JavaScript 函数未在 Firefox 中定义?

javascript - ngFor 中的 Angular2 组件抛出错误(viewFactory 不是函数)

javascript - 使用 React-navigation 进行 React Native 时组件会重新渲染

javascript - 优化数组的结果

reactjs - 使用 JSX React/react-in-jsx-scope 时,“React”必须在范围内吗?

javascript - react Bootstrap 导航栏 : How to right align a navbar item

html - 使用图像链接时标题导航栏消失

html - 在较小的屏幕上调整导航栏的大小并将其向右移动

javascript - 在 ng-click 之后调用的 ng-submit 操作

javascript - 终极版 : Asynchronous action creator not being called