undefinedfix
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
ecisse
commented on Sun, 11 Dec 2022
<span
    @click.stop="handleExpandIconClick"
    :class="[
      { 'is-leaf': node.isLeaf, expanded: !node.isLeaf && expanded },
      'el-tree-node__expand-icon',
      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.

user617562
commented on Sun, 11 Dec 2022

It can be solved by modifying the content of the icon