【问题标题】:Material-UI TreeView heightMaterial-UI TreeView 高度
【发布时间】:2021-02-15 11:54:24
【问题描述】:

有谁知道如何设置material-ui TreeView 固定高度或适合显示的高度?

我希望在 TreeView 内容高度变为 100 或显示高度的 100% 时显示滚动条。现在,当我展开树时,所有不适合的内容都会从显示底部消失。

【问题讨论】:

    标签: javascript reactjs material-ui treeview


    【解决方案1】:

    只需修改TreeView组件的root样式即可。将您想要的高度添加到 height 属性,然后将 overflow 设置为 auto 以使整个 TreeView 组件可滚动。 Sandbox

    const useStyles = makeStyles({
      root: {
        height: "50px",
        flexGrow: 1,
        maxWidth: 400,
        overflow: "auto"
      }
    });
    <TreeView
          className={classes.root}
          defaultCollapseIcon={<ExpandMoreIcon />}
          defaultExpandIcon={<ChevronRightIcon />}
        >
    

    【讨论】:

      猜你喜欢
      • 2019-05-20
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 2018-11-17
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      相关资源
      最近更新 更多