首頁  >  問答  >  主體

如何自訂Antd React目錄樹節點的背景顏色?

<p>如何使用less樣式在滑鼠懸停在樹節點上時更改antd目錄樹節點的預設背景顏色? </p> <pre class="brush:php;toolbar:false;"><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></pre></p>
P粉825079798P粉825079798434 天前699

全部回覆(1)我來回復

  • P粉797855790

    P粉7978557902023-09-04 00:29:16

    <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>

    styles.less

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

    回覆
    0
  • 取消回覆