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)
},
原文地址:https://www.cnblogs.com/cs122/p/9824769.html
时间: 2024-12-04 23:57:13