Javascript 如何以数组中的对象作为条件使用Json表单中的规则?
我将json表单与react一起使用,我想介绍隐藏类别的条件,它将根据数组中的对象显示 这里是伪模式Javascript 如何以数组中的对象作为条件使用Json表单中的规则?,javascript,reactjs,jsonforms,Javascript,Reactjs,Jsonforms,我将json表单与react一起使用,我想介绍隐藏类别的条件,它将根据数组中的对象显示 这里是伪模式 var schema = { "type": "object", "properties": { "name": { "type": "string" }, "alive": { "type": "array", "items": {
var schema = {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"alive": {
"type": "array",
"items": {
"type": "boolean"
}
},
"kindOfDead": {
"type": "string",
"enum": [
"Zombie",
"Vampire",
"Ghoul"
]
}
}
}
var uiSchema = {
"type": "Categorization",
"elements": [
{
"type": "Category",
"label": "Private",
"elements": [
{
"type": "Control",
"label": "Name",
"scope": "#/properties/name"
}
]
},
{
"type": "Category",
"label": "public",
"rule": {
"effect": "DISABLE",
"condition": {
"scope": "#/properties/alive",
"schema": {
"kindOfDead": true
}
}
},
"elements": [
{
"type": "Control",
"label": "Kind of dead",
"scope": "#/properties/kindOfDead"
}
]
}
]
}
var data = {
"name": "John Doe",
"alive": [
isZombie:true,
],
"kindOfDead": "Zombie"
}
因此,在这种情况下,根据isZombie值,该选项卡应被禁用或启用。
isZombie的值由预发送的数据或用户提供