【问题标题】:Maintaining collapse state when drawer opens and closes抽屉打开和关闭时保持折叠状态
【发布时间】:2018-02-03 07:48:50
【问题描述】:

我目前在使用 material-ui 抽屉时遇到问题 (https://material-ui-next.com/ one)

当我打开迷你变体时,我的菜单内的折叠会重置(由于“重新安装”而关闭)。 但是我希望他们保持当前状态(打开/关闭)。

有谁知道实现这一目标的方法吗?



抽屉:

<Drawer type="permanent"
    classes={{paper: classNames(classes.drawerPaper, !this.state.open && classes.drawerPaperClose)}}
    open={this.state.open}>
    <div className={classNames(classes.drawerInner)}>
        <Navigation updateTitle={this.updateTitle}/>
    </div>
</Drawer>



导航组件:https://pastebin.com/webdmLXp



打开折叠渲染:

点击汉堡按钮后:

【问题讨论】:

    标签: reactjs material-ui


    【解决方案1】:

    当然,与我共享姓氏的先生,您需要保留每个 &lt;MenuItem&gt; 的状态。只需向每个 menuItem 添加onClick 并切换组件中的状态。这与Material-ui 并没有真正的关系,而是更普遍的React 问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 1970-01-01
      • 2020-10-26
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多