// 向 info下面 每一项 插入 isShow
test() {
const _this = this;
_this.info.isShow = false;
let iteration = function(arr) {
let newArr = [];
if (arr != undefined && arr.length > 0) {
newArr = arr.map(item => {
item.isShow = false;
if (item.children != undefined && item.children.length > 0) {
iteration(item.children);
}
return item;
});
}
return newArr;
};
_this.info.children = iteration(_this.info.children);
}, // 封装 点击得每个结点的id 和该结点的位置
extendKey(json, nodeId, bol) {
var arr = json.map(item => {
if (item.id == nodeId) {
item.isShow = bol;
} else if (item.mate && item.mate.id == nodeId) {
item.isShow = bol;
} else {
if (item.children) {
this.extendKey(item.children, nodeId, bol);
}
}
return item;
});
return arr;
},