Antd React自定义目录树节点背景?

huangapple go评论67阅读模式
英文:

Antd react customize directrory tree node background?

问题

如何使用Less样式在鼠标悬停在antd目录树节点上时更改树节点的默认背景颜色?

 <Tree.DirectoryTree>
        {data.map((item) => {
          return (
            <Tree.TreeNode
              // @ts-ignore
              item={item}
              icon={<></>}
              key={item.user_folder_id}
              title={item.title}
            >
              {item?.data.map((node) => {
                return (
                  <Tree.TreeNode
                    node={node}
                    key={node.node_id}
                    title={ node.title }
                  ></Tree.TreeNode>
                );
              })}

            </Tree.TreeNode>
          );
        })}
      </Tree.DirectoryTree>
英文:

How to change the default background color of antd directory tree node when mouseover the tree node using less styles ?


 <Tree.DirectoryTree>
        {data.map((item) => {
          return (
            <Tree.TreeNode
              // @ts-ignore
              item={item}
              icon={<></>}
              key={item.user_folder_id}
              title={item.title}
            >
              {item?.data.map((node) => {
                return (
                  <Tree.TreeNode
                    node={node}
                    key={node.node_id}
                    title={ node.title }
                  ></Tree.TreeNode>
                );
              })}

            </Tree.TreeNode>
          );
        })}
      </Tree.DirectoryTree>

答案1

得分: 0

 <Tree.DirectoryTree className="custom-tree">
        {data.map((item) => {
          return (
            <Tree.TreeNode
              // @ts-ignore
              item={item}
              icon={<></>}
              key={item.user_folder_id}
              title={item.title}
            >
              {item?.data.map((node) => {
                return (
                  <Tree.TreeNode
                    node={node}
                    key={node.node_id}
                    title={ node.title }
                  ></Tree.TreeNode>
                );
              })}

            </Tree.TreeNode>
          );
        })}
      </Tree.DirectoryTree>
.custom-tree .ant-tree-treenode:hover::before {
  background: blue !important;
}
英文:
 &lt;Tree.DirectoryTree className=&quot;custom-tree&quot;&gt;
        {data.map((item) =&gt; {
          return (
            &lt;Tree.TreeNode
              // @ts-ignore
              item={item}
              icon={&lt;&gt;&lt;/&gt;}
              key={item.user_folder_id}
              title={item.title}
            &gt;
              {item?.data.map((node) =&gt; {
                return (
                  &lt;Tree.TreeNode
                    node={node}
                    key={node.node_id}
                    title={ node.title }
                  &gt;&lt;/Tree.TreeNode&gt;
                );
              })}

            &lt;/Tree.TreeNode&gt;
          );
        })}
      &lt;/Tree.DirectoryTree&gt;

styles.less

.custom-tree .ant-tree-treenode:hover::before {
  background: blue !important;
}

huangapple
  • 本文由 发表于 2023年2月13日 23:21:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75437842.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定