我正在关闭权限 ID 并尝试过滤具有这些权限的对象。这是 JSON 对象的简洁版本
[
{
"id": "INS-SH-V",
"name": "View Sharing Functionality",
"description": "Access to view Email and Schedule windows",
"group": "Sharing",
"scopeable": false,
"featureId": "INS-BE",
"scopeExclusions": null,
"dependsOn": null
},
{
"id": "INS-SH-U",
"name": "Manage Sharing Functionality",
"description": "Access to send emails and schedule jobs",
"group": "Sharing",
"scopeable": false,
"featureId": "INS-BE",
"scopeExclusions": null,
"dependsOn": [
"INS-SH-V"
]
}
]
基本上我被给定INS-SH-V并且想要扫描每个dependsOn属性中的所有项目,如果INS-SH-V有那么我想返回id那个对象的。有没有一种简单的方法可以做到这一点?我一直在努力让它在 for 循环中工作。
谢谢!
到目前为止,这是我的尝试:
let len = this.props.permissions.length;
for (let i = 0; i < len; i++){
if (this.props.permissions[i].dependsOn[0] !== null){
// return this.props.permissions[i].id // Should return INS-SH-U
if (permissionId === this.props.permissions[i].dependsOn[0]){
// return this.props.permissions[i].id
console.log(this.props.permissions[i].id);
}
}
}
return null;
慕桂英3389331
当年话下
慕标5832272
冉冉说
相关分类