【问题标题】:material-ui toggle leftnav when user clicks inside the application area当用户在应用程序区域内单击时,material-ui 切换 leftnav
【发布时间】:2016-02-12 15:54:38
【问题描述】:

我在AppBar 中使用切换开关来显示LeftNav。再次单击切换时,我可以关闭 LeftNav。但我也想要大多数左侧导航的行为,其中用户在屏幕内单击并且左侧导航滑出。即单击 LeftNav 以外的任何位置以自动关闭。以前有人做过吗?

<LeftNav open={this.state.open} openRight="{true}">
                    <MenuItem>Menu Item</MenuItem>
                    <MenuItem>Menu Item 2</MenuItem>
</LeftNav>

【问题讨论】:

    标签: javascript reactjs material-ui


    【解决方案1】:

    添加 onRequestChange 处理程序:

    onRequestChange={this.onLeftNavClose.bind(this)}
    
    onLeftNavClose(flag, reason) {
             if (!flag && reason === 'clickaway') {
                this.state.open = false; 
             }
      }
    

    【讨论】:

      猜你喜欢
      • 2015-09-26
      • 2015-04-25
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多