{
"data": [
{
"id": "2",
"pid": "1",
"name": "Joyce@163.com",
"uid": "2",
"children": [
{
"id": "3",
"pid": "2",
"name": "flow01@163.com",
"uid": "3",
"children": []
},
{
"id": "4",
"pid": "2",
"name": "0",
"uid": "4",
"children": []
},
{
"id": "33",
"pid": "2",
"name": "0",
"uid": "37",
"children": []
},
{
"id": "101",
"pid": "2",
"name": "1195154798@qq.com",
"uid": "116",
"children": []
},
{
"id": "102",
"pid": "2",
"name": "device02@163.com",
"uid": "117",
"children": []
},
{
"id": "103",
"pid": "2",
"name": "flow@163.com",
"uid": "118",
"children": []
}
]
}
],
"code": 0,
"message": ""
}
后台返回的数据是name的键值对,但是业务需求要以title的键值对,方法如下
var treeList = JSON.parse(JSON.stringify(data).replace(/name/g, 'title'))
console.log(treeList)