如何過濾數組對象和子節點對象中某一屬性不符合條件的
阿新 • • 發佈:2018-10-21
name EDA del fff 對象 ole address nbsp current
tableData:[],//過濾後的數據
datalist:[//過濾前的數據
{name:‘chen‘,age:‘18‘,address:‘1‘,id:‘1‘,delete:false, edit:false,child:[{name:‘chen1‘,delete:false,address:‘12‘,age:‘18‘,child:[]}]},
{name:‘chen‘,age:‘18‘,address:‘2‘,id:‘2‘,delete:false, edit:false,child:[{name:‘chen‘,delete:false,age:‘18‘,address:‘12‘,child:[]}]}],
filterDeletedRow (data=this.datalist , root=true, currentNode) {
if(!root){
currentNode.child = []
}else{
this.tableData = []
}
let children
data.forEach(data => {
if(!data.delete){
children = root ? this.tableData : currentNode.child
children.push(data)
this.filterDeletedRow(data.child,false,data)
}
});
console.log(this.tableData)
},
如何過濾數組對象和子節點對象中某一屬性不符合條件的