import Tree from '@/components/tree/index.vue' import {GetOrganiztionalData,GetUserList} from '@/api/detailedList' export default { components: {Tree}, data() { return { data: [] } }, props: { treeUserInfo: Object }, created() { this.getOrganizational() }, methods: { // 辅助函数:根据部门ID找到对应的部门节点 findDepartmentNode(departmentId, nodes) { for (const node of nodes) { if (node.id === departmentId) { return node; } // 如果该节点有子节点,递归查找 if (node.children && node.children.length > 0) { const foundNode = this.findDepartmentNode(departmentId, node.children); if (foundNode) { return foundNode; } } } return null; // 如果找不到对应的部门节点 }, getOrganizational() { GetOrganiztionalData({}).then(res => { if(this.treeUserInfo.erpCode) { console.log('2222') this.data = [res.data] const id = this.treeUserInfo.erpDepCode this.getUserInfo(id) } else { this.data = [res.data] } }) }, getUserInfo(id) { const departmentNode = this.findDepartmentNode(id, this.data) if(!departmentNode.children) { this.$set(departmentNode, 'children', []) } const obj = { erpParentCode: id } let array = [] GetUserList(obj).then(res => { res.data.map(item => { array.push({ text:item.erpName, erpCode: item.erpCode }) }) departmentNode.children.push(...array) }) } }, } 这是我写的代码,走console.log('222')的时候,传递给子组件的 data数据没有,应该怎么解决 子组件代码 export default { data() { return { defaultCheckKeys: [] } }, props: { data: Array, keys:String }, methods: { handleExpandClick(node,data) { node.expanded = !node.expanded; } }