In iview, tree cannot change checked to false

do permission control, and it is possible to select and display the tree table and set checked=true, according to the permissions sent back by the background. If you change the permission setting, the checked=false, will fail, and the checked will still be true

. < hr >
this.permissionTree[0].children.forEach((item, index) => {
                if (item.children.length>=0) {
                    let childrenArr = [];
                    childrenArr = item.children.filter(child => {
                        if (child.permission !== undefined) {
                            if (role.permissions.indexOf(child.permission) >= 0) {
                                child.checked = true;
                            }else{
                                child.checked = false;
                            };
                            return child;
                        } else {
                            return child;
                        }
                    });
                    if(childrenArr.length>0){
                        item.children=childrenArr;
                        permissionTreeList.push(item);
                    }   
                    console.info("childrenArr",childrenArr)                
                }                
            });
Mar.19,2021

this.permissionTree[0].children.map    

should be this ide/reactivity.html" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.


the internal update of the array did not trigger the view update. It's been given to the portal upstairs.


probably know that the view is not updated, but I still don't have a solution. Tree seems to have no clear () method


2.0 array does not support responsive, use this.$set (child.checked, false)


try emptying the data of the Tree component before the update, and if the child modification is not successful, make a deep copy of the original initialized Tree component data array and then render it again.
the following is the deep copy code
`
const deepCopy = (source) = > {
var sourceCopy = source instanceof Array? []: {};
for (var item in source) {

sourceCopy[item] = typeof source[item] === 'object' ?  objDeepCopy(source[item]) : source[item];

}
return sourceCopy;
}
`source is the original Tree component data array code, and then re-render the Tree component data

Menu