How to set highlight for element-ui tree control

  1. uses the control of element-ui tree, and the structure is shown in the following figure
  2. requirements: when I click on the right level 3 1-1-1 file, how do I make the tree level 3 1-1-1 node highlight (that is, how to highlight the tree node that meets a certain condition), at the same time, if the current tree level 1-1 is a collapsed state, how do I make it show an expanded state. I would like to ask all the great gods.

    clipboard.png


add an attribute highlight-current does not need to give any value


there is a setCurrentKey () method in the tree, you can display the highlight effect according to the node id, here is the tree, some of the attributes you set (attributes can be added or subtracted according to the document, here is just a reference for you)

<el-tree
  ref="tree"
  :data="data"
  node-key="id"
  show-checkbox
  check-strictly
  highlight-current
  :expand-on-click-node="false"
  />

call this method directly
this.$refs.tree.setCurrentKey (node id)

Menu