1 ChuliSelectList() { 2 // chooseArr 3 for (let i = 0; i < this.chooseArr.length; i++) { 4 let item = this.chooseArr[i] 5 this.selectIds.push(item.name) 6 } 7 console.log("选中的id",this.selectIds) 8 this.chuliTestList(this.testList) 9 }, 10 chuliTestList(list, parentIsChoose) { 11 for (let i = 0; i < list.length; i++) { 12 let item = list[i] 13 let isSelect = this.selectIds.filter(selectName => { 14 if (selectName == item.name) { 15 return selectName 16 } 17 }) 18 19 if (parentIsChoose || isSelect.length) { 20 this.$set(item, "isChoose", true) 21 } 22 if (item.children && item.children.length) { 23 this.chuliTestList(item.children, item.isChoose) 24 } 25 } 26 console.log("结果呀", this.testList) 27 }