选中删除数据的时候,选中的数据id会组成一个数组,然后从所有的数据数组的第一层里删掉这个数据,同时如果数据有children,children里有这条数据,那就从第一层里删除这条数据
data = [{
flg: "0",
id: "1001",
name: "一级1",
children: [{
flg: "0",
id: "100101",
name: "二级1"
}, {
flg: "0",
id: "100102",
name: "二级2"
}, {
flg: "0",
id: "100103",
name: "二级3"
}]
}, {
flg: "0",
id: "100101",
name: "二级1"
}, {
flg: "0",
id: "100102",
name: "二级2"
}, {
flg: "0",
id: "100103",
name: "二级3"
}]
cacel = ['100103']
要得到的数据是
[{
flg: "0",
id: "100101",
name: "二级1"
}, {
flg: "0",
id: "100102",
name: "二级2"
}]
主要用到了递归
可执行例子:
https://codepen.io/LiangWei88...
代码: