【问题标题】:ListItem in material UI reactjs材料UI reactjs中的ListItem
【发布时间】:2018-04-16 07:28:58
【问题描述】:

我一直在尝试对带有孩子的 ListItem 使用自定义按钮。我可以使用 ListItem 的 rightIconButton 道具更改打开按钮,但在切换后无法更改。我曾尝试使用 ListItem 的 rightToggle 道具,但仍然无法正常工作。

<ListItem 
  style={{height: 46}} 
  nestedListStyle={{padding: 0}}
  key={key}
  open={this.checkOpenMenu()}
  primaryTogglesNestedList={true}
  primaryText='test'
  rightIconButton = {
    <IconButton style={{}}><img src={baseUrl + "/open.svg" } alt="More" />
    </IconButton>}
  rightToggle = {
    <IconButton style={{}}><img src={baseUrl + "/close.svg" } alt="More" />
    </IconButton>}
  nestedItems={children}
/>);

【问题讨论】:

    标签: reactjs material-ui


    【解决方案1】:

    终于找到答案了

    <ListItem 
      style={{height: 46}} 
      nestedListStyle={{padding: 0}}
      key={key}
      open={this.checkOpenMenu()}
      primaryTogglesNestedList={true}
      primaryText='test'
      rightIconButton = { condition ? <IconButton><img src={baseUrl + "/close.svg" } alt="More" /></IconButton> : <IconButton><img src={baseUrl + "/open.svg" } alt="More" /></IconButton>}
      nestedItems={children}
    />);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-22
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2021-05-10
      相关资源
      最近更新 更多