this.network.nodeList.forEach((node) => { //过滤出符合条件的节点 let people:any = this.peopleList.filter((item) => item.name ===node.name); node.relation = people[0].relation; });
people是一个array,只包含一个对象,所以在获取的时候需要使用index=0,否则直接使用会undefined
this.network.nodeList.forEach((node) => { //过滤出符合条件的节点 let people:any = this.peopleList.filter((item) => item.name ===node.name); node.relation = people[0].relation; });
people是一个array,只包含一个对象,所以在获取的时候需要使用index=0,否则直接使用会undefined
转载于:https://my.oschina.net/u/2499632/blog/749097