最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How add a icon in my TreeItem Material UI 4 - Stack Overflow

programmeradmin4浏览0评论

I have a menu made with MATERIAL UI 4, it is posed of a first TreeItem with my main menu and a second TreeItem with my submenu.

I would like to add a specific icon to each label of the main menu.

How can I do ?

Is it possible that when I click on two drop-down menus, the first is reset by default ( no dropdown ).

    {stoMenu && (
      <TreeView
        style={test.menu}
      >
        {Menu.root.children.map(test=> {
          return (
            <TreeItem
              key={test.nodeId}
              nodeId={test.nodeId}
              label={test.text}
            >
              {test.children.map(child => {
                return (
                  <TreeItem
                    key={child.nodeId}
                    nodeId={child.nodeId}
                    label={child.text}
                  >
                    <Redirect to={child.id} />
                  </TreeItem>
                );
              })}
            </TreeItem>
          );
        })}
      </TreeView>
    )}

I have a menu made with MATERIAL UI 4, it is posed of a first TreeItem with my main menu and a second TreeItem with my submenu.

I would like to add a specific icon to each label of the main menu.

How can I do ?

Is it possible that when I click on two drop-down menus, the first is reset by default ( no dropdown ).

    {stoMenu && (
      <TreeView
        style={test.menu}
      >
        {Menu.root.children.map(test=> {
          return (
            <TreeItem
              key={test.nodeId}
              nodeId={test.nodeId}
              label={test.text}
            >
              {test.children.map(child => {
                return (
                  <TreeItem
                    key={child.nodeId}
                    nodeId={child.nodeId}
                    label={child.text}
                  >
                    <Redirect to={child.id} />
                  </TreeItem>
                );
              })}
            </TreeItem>
          );
        })}
      </TreeView>
    )}
Share edited Sep 23, 2019 at 15:22 Paul Hub asked Sep 19, 2019 at 8:00 Paul HubPaul Hub 1813 silver badges9 bronze badges 1
  • 1 Please mark answer as accepted if that helped you :) – Eugene Chybisov Commented Sep 20, 2019 at 8:34
Add a ment  | 

1 Answer 1

Reset to default 6

They have great example how to do that https://codesandbox.io/s/material-demo-ui4dx

Also be careful with TreeView ponent as it is still in Lab and can be with some issues and not finished implementation.

发布评论

评论列表(0)

  1. 暂无评论