1 handleItemChange(val) { 2 console.log(val, '----') 3 console.log(this.defaultOptions, '二二二') 4 var code = val[val.length - 1] 5 6 var level = this.getlevel(code, this.defaultOptions) //递归执行函数 7 console.log(level, '递归查出来的level') 8 9 this.defaultOptions = this.handleData(this.defaultOptions, code, level) 10 }, 11 //递归查divlevel 12 getlevel(code, defaultOptions) { 13 console.log(code, defaultOptions, '555555') 14 let divLevel = '' 15 defaultOptions.forEach(item => { 16 if (item.divCode === code) { 17 divLevel = item.divLevel 18 } else { 19 let tmp = this.getlevel(code, item.children) 20 if (tmp && tmp.length != 0) { 21 divLevel = tmp 22 return tmp 23 } 24 } 25 }) 26 return divLevel 27 }