js部分 具体实现需要根据需求更改参数这里只是提供了获取节点的方法
getKeys() { var aKey = this.getCheckedKeys(this.treeData, this.$refs.rootTree.getCheckedKeys(), 'menuId'); var result = []; var obj = {}; this.PermissionList=aKey //tree父节点去重 for (var i =0; i<this.PermissionList.length; i++) { if(!obj[this.PermissionList[i].permissionId]){ result.push(this.PermissionList[i]); obj[this.PermissionList[i].permissionId] = true; } } //回调 getCheckedKeys (data, keys, key) { var res = []; recursion(data, false); return res; // arr -> 树形总数据 // keys -> getCheckedKeys获取到的选中key值 // isChild -> 用来判断是否是子节点 function recursion (arr, isChild) { var aCheck = []; for ( var i = 0; i < arr.length; i++ ) { var obj = arr[i]; aCheck[i] = false; if ( obj.children ) { aCheck[i] = recursion(obj.children, true) ? true : aCheck[i]; if ( aCheck[i] ) { res.push({permissionId:obj[key]}); } } for ( var j = 0; j < keys.length; j++ ) { if ( obj[key] == keys[j] ) { aCheck[i] = true; if ( res.indexOf(obj[key]) == -1 ) { res.push({permissionId:obj[key]}); } break; } } } if ( isChild ) { return aCheck.indexOf(true) != -1; } } }