element-Plus el-tree lazy loading vue3 partial refresh

1. First add ref to the el-tree component

<el-tree node-key="unid" ref="treeRef" />

2. Get ref

const treeRef = ref()

3. The method of reloading the node, as long as the unid is passed in, we think that  the node-key  above is bound to  the unid

const refreshTreeNode = (unid) => {
  let node = treeRef.value.getNode(unid);
  if (node) {
    node.loaded = false;    //告诉组件这个节点需要加载
    node.expand(); // 主动调用展开节点方法,重新查询该节点下的所有子节点
  }
}

4. Call it wherever you need it

refreshTreeNode(unid)

Guess you like

Origin blog.csdn.net/weixin_50587417/article/details/130768316