点击以后,取出当前节点,然后用另外的form,提交之后用代码把修改覆盖到树绑定的对象里。这是我的做法 <el-tree ref="tree" :props="props" :load="loadChild" lazy @current-change="SwitchNode" :accordion="true" style="max-height:800px;min-height:400px;background-color:rgba(0,0,0,0.005);box-shadow:0 0 4px 0 #999 inset;padding:10px;user-select:none" > </el-tree> 这是获取选中的node SwitchNode(data,node){ this.form.id = data.Id; this.form.label = data.label; this.form.node = node; }, 这是更新的: async UpdateLabel(){ if(this.form.NewName.length===0){ this.$eve.emit("error","不能为空"); return; } let node = this.form.node; let name = this.form.NewName; let res= await this.$api("sys_department",{cmd:"updatelabel",id:this.form.id,name}); if(res.status === 200){ node.data.label = name; this.form.NewName = ""; this.form.label = name; this.$eve.emit("success","修改成功"); }else{ this.$eve.emit("error",res.msg); } }, 我在Form那个对象里直接把node拿到了,所以直接用node.data.label = str就可以更新了
点击以后,取出当前节点,然后用另外的form,提交之后用代码把修改覆盖到树绑定的对象里。这是我的做法
这是获取选中的node
这是更新的:
我在Form那个对象里直接把node拿到了,所以直接用
node.data.label = str
就可以更新了