标签:amp load reduce dde second 操作 数据操作 stc color
1.数组处理添加与拼接
this.treeListData.push(res.payload.results.OADepartment); var treeList = this.treeListData[0].children; var treeL = []; treeList.forEach(el =>{ if(el.children){ treeL.push(el.children);//添加到数组 } }); var treeLi = []; var len = treeL.length; for(var i=0;i<len;i++){ treeLi.push.apply(treeLi,treeL[i]);//拼接数组 } this.listSecondDepart = treeLi;
2.数组对象排重reduce()
var hash = {};
var arr = this.listCheckDepart;
arr = arr.reduce(function(item, next) {
hash[next.id] ? ‘‘ : hash[next.id] = true && item.push(next);
return item
}, [])
this.listCheckDepart = arr;
标签:amp load reduce dde second 操作 数据操作 stc color
原文地址:https://www.cnblogs.com/cx709452428/p/9712252.html