我需要在 ui-schema 中有一些字段,这些字段在 schema 部分中不存在

I need to have some fields in ui-schema which do not exist in schema section

我以前用jsonform in my project but now I migrate to react, So I use this library (react-jsonschema-form)。 在 jsonform 中,我可以在表单部分中有一些不在模式中的字段集。像这样:

{
  "schema":
    {
      "firstName": {
      "type": "string",
      "title": "Is JSON Form useful?",
      }
    },
  "form": [
     {
      "key": "firstName",
      "type": "text",
     }, 
     {
      "title" : "this is non-schema",
      "type": "fieldset"
     }
   ]
}

您可以在 jsonschema playground 进行测试。 请帮助我在 react-jsonschema-form 中执行类似上述代码的操作。 我怎样才能拥有一些不在模式中但我想在 uiSchema 中显示它们的字段?

react-jsonschema-form 也有一个 playground。您可以找到一个名为 'date' 的字段。它添加在 uiSchema 中,但它不存在于 schema 部分中。结果中此字段也没有任何显示。如果它不存在,我不知道他们为什么要使用它!!!!

谢谢。

日期只是 uiSchema 的一个示例,playground 只是不使用它 time.And 我创建了一个示例来帮助理解。

JSONSchema

{
  "title": "An example form",
  "description": "A simple form example",
  "type": "object",
  "required": [
    "firstName",
    "lastName"
  ],
  "properties": {
    "firstName": {
      "type": "string",
      "title": "First name"
    },
    "age": {
      "type": "integer",
      "title": "Age"
    },
    "telephone": {
      "type": "string",
      "title": "Telephone",
      "minLength": 10
    },
    "date": {
      "type": "string",
      "title": "Date"
    }
  }
}

UISchema

{
  "firstName": {
    "ui:autofocus": true,
    "ui:emptyValue": ""
  },
  "age": {
    "ui:widget": "updown",
    "ui:title": "Age of person",
    "ui:description": "(earthian year)"
  },
  "date": {
    "ui:widget": "alt-datetime"
  },
  "telephone": {
    "ui:options": {
      "inputType": "tel"
    }
  }
}

properties中有四个JSONSchema:firstName,age,telephone,date.AndUISchema中有四个:firstName,age,telephone,date.They是same.Each中的一个JSONSchema 在 JSONSchema 中有一个或更少的 UISchema.The 类型,如字符串,在字符串中有一些子选项,如 "updown"。我们在 ui:ui:widget(UISchema) 中设置它。这是我的 result.The 底部元素是您提到的日期。