El-tree in elementui, data echo problem

when the el-tree related array is returned in the background, the submenus are not all selected, but as long as the id of the parent menu is in the array, then his submenus are all selected

clipboard.png

clipboard.png

method used

this.$axios.get("menu/queryMenuIdList?roleId=" + row.roleId).then(res => {
                   this.defalutArr = res.data
                   this.$refs.tree.setCheckedKeys(this.defalutArr);
                   })

after reading the document, it is said that as long as the included id in the array returned by the setCheckedKey () method is selected, it will be set to the selected state instead of the semi-selected state. Call for help


do not use setCheckedKeys to echo the data. After getting the id array from the back end, use setChecked to cycle through the selected state.
another thing to note is that if using setChecked doesn't work, add a setTimeout to it, or get the data and then process it with a then.


drop the parent id Filter in this.defalutArr


I would like to ask the subject, how to solve the first kind of question you asked? my data is also an array of this kind of data. If there is a parent ID in it, all the children below the parent will be selected. How do you solve it? Thank you so much for waiting online


Hello, how to use setChecked, I didn't respond when I used it.

Menu