TreeView
组件的 root
样式。将您所需的高度添加到 height
属性中,然后将 overflow
分配为自动以使整个 TreeView
组件可滚动。 沙盒。const useStyles = makeStyles({
root: {
height: "50px",
flexGrow: 1,
maxWidth: 400,
overflow: "auto"
}
});
<TreeView
className={classes.root}
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
>