elementui tree懒加载时 的节点的移除、更新

移除节点

this.$refs.$_tree.remove(tempNode)

更新某个节点

if (顶层节点) {
    
    
	// 清空 重新赋值
	this.treeData = []
    this.treeData = res.data
} else {
    
    
    // 非顶层节点,key更新节点的id
	this.$refs.$_tree.updateKeyChildren(key, res.data)
}

常用的tree的方法

 // 获取指定节点
 const targetNode = this.$refs.$_tree.getNode(this.targetFolder)
 // 展开指定节点
 targetNode.expand()
 // 选中指定节点
 this.$refs.$_tree.setCurrentKey(tempNode.data.value)

猜你喜欢

转载自blog.csdn.net/qq_45616003/article/details/127702273