1.el-tree设置 node-key,current-node-key,default-expanded-keys,highlight-current:
html
<el-tree
ref="taskTree"
:data="ptreeData"
node-key="key"
:current-node-key="currentKey"
:default-expanded-keys="defaultExpanded"
highlight-current>
</el-tree>
2.赋值数据
html
nextTick(() => {
currentKey.value=firstNode.key;
taskTree.value.setCurrentKey(firstNode.key);
defaultExpanded.value=nodeIds;
})
注意:使用了nextTick。