简体   繁体   English

如何创建折叠的侧面菜单栏?

[英]How to create collasped side menu bar?

I want to add a side menu bar in my react application.我想在我的 React 应用程序中添加一个侧面菜单栏。 Initially it should be closed only icons should be visible and on clicking on one icon entire sidemenu should menu..I am doing this way But it is not closing and is not closing.. I tried out different ways but not able to achieve it最初它应该关闭只有图标应该是可见的并且点击一个图标整个侧边菜单应该菜单..我这样做但是它没有关闭也没有关闭..我尝试了不同的方法但无法实现它

In parent component:在父组件中:

const [show, setShow] = React.useState(false)

return <div>{show ? <SideMenu /> : <Icon />}</div>

If I understood an issue properly.如果我正确地理解了一个问题。

And use onClick in Icon to change show state.并在图标中使用 onClick 更改显示 state。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM