1 // 向 info下面 每一项 插入 isShow
2 test() {
3 const _this = this;
4 _this.info.isShow = false;
5 let iteration = function(arr) {
6 let newArr = [];
7 if (arr != undefined && arr.length > 0) {
8 newArr = arr.map(item => {
9 item.isShow = false;
10 if (item.children != undefined && item.children.length > 0) {
11 iteration(item.children);
12 }
13 return item;
14 });
15 }
16 return newArr;
17 };
18 _this.info.children = iteration(_this.info.children);
19 },
20
21 // 封装 点击得每个结点的id 和该结点的位置
22 extendKey(json, nodeId, bol) {
23 var arr = json.map(item => {
24 if (item.id == nodeId) {
25 item.isShow = bol;
26 } else if (item.mate && item.mate.id == nodeId) {
27 item.isShow = bol;
28 } else {
29 if (item.children) {
30 this.extendKey(item.children, nodeId, bol);
31 }
32 }
33 return item;
34 });
35 return arr;
36 },