原因是数据是异步请求返回的,getNode方法在nextTick中调用就解决问题了
this.$post("label/tree", {}).then((res) => {
this.tree = res.data;
this.$nextTick(()=>{
this.$refs.tree.setChecked(this.tagId,true)
let node = this.$refs.tree.getNode({ id: this.tagId })
this.tagName = node.label;
})
});