简体   繁体   English

如何在 ReactJS 中的 TreeView 材质 UI 中放置结束图标?

[英]How can I put end Icon in TreeView Material UI in ReactJS?

I'm using React TreeItem material UI.我正在使用 React TreeItem材质 UI。 I am using the custom StyledTreeItem function from here .我从这里使用自定义StyledTreeItem function 。 The thign I want is icon at the end of label.我想要的是 label 末尾的图标。 I want to use endIcon but it is not working.我想使用endIcon但它不起作用。

Here is the code which I have done so far: <StyledTreeItem endIcon={ArrowDropDownIcon}></StyledTreeItem>;这是我到目前为止所做的代码: <StyledTreeItem endIcon={ArrowDropDownIcon}></StyledTreeItem>;

What I want to do is to use SVG icon in endIcon like this: <StyledTreeItem endIcon={<ArrowDropDownIcon />}></StyledTreeItem>;我想做的是在endIcon中使用 SVG 图标,如下所示: <StyledTreeItem endIcon={<ArrowDropDownIcon />}></StyledTreeItem>;

The function which I'm using has been taken from here .我使用的 function 取自这里

But somehow it is not working.但不知何故,它不起作用。

Is this achievable?这是可以实现的吗? How can I do this?我怎样才能做到这一点?

endIcon property doesn't place the icon at the end of label but it places the icon beside the last child of the node. endIcon 属性不会将图标放在 label 的末尾,但会将图标放在节点的最后一个子节点旁边。 TreeItem API树项 API

However, if you need your icon to be placed at the end of label, it can be achieved with css.但是,如果您需要将您的图标放在 label 的末尾,则可以通过 css 来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Material UI 按钮的角落放置一个图标 - How to put an icon on in the corner of a Material UI button ReactJS:展开后如何折叠 Material UI TreeView? - ReactJS: How to collapse Material UI TreeView after expanding? 如何更改 KeyboardTimePicker (material-ui-pickers) 中的图标? - How can I change icon in the KeyboardTimePicker (material-ui-pickers)? Material-ui 标签 - 我如何放置它们的滚动 - Material-ui Tabs - how can I put scroll of them 在展开一个组件(Material-UI + ReactJS)时,如何保留组件(卡片组件)的位置? - How can I retain the position of components (Card component) while one is expanded (Material-UI + ReactJS)? ReactJS:如何将Material-UI的占位符和文本居中 <DatePicker/> ? - ReactJS: How can I center the placeholder and text for Material-UI's <DatePicker/>? 如何使用 CSS @media 响应 Reactjs Material UI 上的 makeStyles? - How can I use CSS @media for responsive with makeStyles on Reactjs Material UI? 如何使用 X 图标而不是仅通过在模态外单击来关闭 Material UI 模态? - How can I close a Material UI Modal using an X icon rather than just by clicking outside the modal? 如何在 React 的图标按钮(材质 UI)中使用 input type='text'? - How can I use input type='text' in a Icon Button (Material UI) in React? Material-UI:如何在 TreeView 中添加边框 - Material-UI: How to add border in TreeView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM