js 修改属性名和值。并只保留需要的属性
result.data =
[
{
id: "0c4a850086f211eb88ce2e17e48e1195",
name: "创新园二期",
parentId: "0",
iconSkin: "group",
isParent: true,
orgNode: true,
limit: false,
polygon: null,
lng: null,
lat: null,
mapImage: null,
mobile: null,
userId: null,
type: 0,
code: null,
username: null,
chief: null,
checked: false,
nodes: null,
},
{
id: "0c4a850086f211eb88ce2e17e48e11951111",
name: "创新园二期11111",
parentId: "0",
iconSkin: "group",
isParent: true,
orgNode: true,
limit: false,
polygon: null,
lng: null,
lat: null,
mapImage: null,
mobile: null,
userId: null,
type: 0,
code: null,
username: null,
chief: null,
checked: false,
nodes: null,
},
];
this.treedata = result.data; if (this.treedata && this.treedata.length != 0) {
//删除其他不需要的属性 this.treedata = this.treedata.map((item, index) => {
item["title"] = item.name;
return Object.assign( {}, { title: item.title }, { loading: false }, { children: [] }, { id: item.id, } ); }); } console.log(222, this.treedata);
得到的结果。