首页 > 解决方案 > 覆盖整个宽度的反应侧边栏

问题描述

我在我的项目中使用以下侧边栏

https://reactjsexample.com/minimal-side-navigation-component-for-react/

但是,如果我制作了组件并将其导入到我的页面中,它会跨越整个页面,而其余内容则位于其下方。我有这两种方式:

return (
        <>
            <Sidebar />
            <Router>
                    <Redirect path='/user-portal' to='/user-portal/dashboard' exact />
                    <Route path='/user-portal/Dashboard' component={Dashboard} exact />
            </Router>
        </>
    )

return (
        <>
            <Sidebar>
                <Router>
                        <Redirect path='/user-portal' to='/user-portal/dashboard' exact />
                        <Route path='/user-portal/Dashboard' component={Dashboard} exact />
                </Router>
            </Sidebar>
        </>
    )

标签: javascriptreactjsjsx

解决方案


推荐阅读