// 返回tree
<el-tree
ref="testTree"
class="tree"
:data="treeData"
node-key="id"
icon-class="none"
default-expand-all // 默认展开树
:highlight-current="true"
@node-click="handleNodeClick"
>
treeData:[] // 定义treeData,类型为数组
// 获取treeData的方法
getTreeData(){
this.treeData = response.data
this.$refs.testTree.setCurrentKey(response.data[0].id) // 选中第一个节点样式回显
this.handleNodeClick(this.treeData[0]) // 选中第一个节点后调用的方法
}
// 节点被点击时的回调方法(可做进一步查询操作等)
handleNodeClick(data){}