Sign in

How to set expansion and collapse icons for element UI tree

qjnnp edited in Sat, 10 Dec 2022

Set icon in treedata and render through rendercontent. The icon is replaced successfully. However, different icons need to be set for expansion and collapse. How do you set them?

2 Replies
commented on Sun, 11 Dec 2022
      { 'is-leaf': node.isLeaf, expanded: !node.isLeaf && expanded },
      tree.iconClass ? tree.iconClass : 'el-icon-caret-right'

The logic in the source code is like this: iconclass sets the expansion icon, and the folding icon rotates 90 degrees.

Rendercontent is used to set the content in the tree.

commented on Sun, 11 Dec 2022

It can be solved by modifying the content of the icon