The element-ui tree component cannot be referenced

when using the element-ui tree component, the data is normally obtained from the background, and the ref property is also written, but there is no reference to this component in the method, so it is impossible to set the value checked by the tree component. There is still a lot of bug for this tree component.

<el-tree
  :data="treeData"
  show-checkbox
  ref="tree"
  node-key="_id"
:default-checked-keys="tree_checked">
</el-tree>

this.$refs.tree.setCheckedKeys(row.role)

Call this.$refs.tree, in the

method to report an error undefined does not have this component, what is the matter? Confused me

Mar.20,2021

where did you call it? make sure that dom has been loaded


. Your invisible


element official website says that although calling tree, in the open event can be used, the console will report an error. Finally, I chose the open event and then called the timer, so that in the next event cycle, it will not report errors and can be used

.
Menu