数组数据添加parentId|数组数据添加parentId,parentIds,isChild字段

给排序过的数据添加parentId,parentIds,isChild字段

function add_parentIds(test){![微信图片_20200212173029.jpg](https://upload-images.jianshu.io/upload_images/16566662-5819308b088285fd.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)let num = ''; ![微信图片_20200217221854.png](https://upload-images.jianshu.io/upload_images/16566662-76d8586bc7c7ce76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)for(let i=0; i test[i]['level']){ test[i]['isChild'] = true; test[j]['parentId'] = test[i]['id']; num += test[i]['id'] + ','; test[j]['parentIds'] = num; }else{ test[i]['isChild'] = false; num = ''; } } } return test; }```![微信图片_20200212173029.jpg](https://upload-images.jianshu.io/upload_images/16566662-483d54a66a6a7c98.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

    推荐阅读