3

我正在使用带有 react 的 json-forms,我想引入隐藏类别的条件,它将根据数组内的对象显示。

这是伪模式

       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 的值是从当前发送的数据或用户提供的

4

0 回答 0