Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 我需要在ui模式中有一些在模式部分中不存在的字段_Json_Reactjs_React Jsonschema Forms - Fatal编程技术网

Json 我需要在ui模式中有一些在模式部分中不存在的字段

Json 我需要在ui模式中有一些在模式部分中不存在的字段,json,reactjs,react-jsonschema-forms,Json,Reactjs,React Jsonschema Forms,我以前在我的项目中使用,但现在我迁移到react,所以我使用这个库()。 在jsonform中,我可以在表单部分中有一些不在模式中的字段集。像这样: { "schema": { "firstName": { "type": "string", "title": "Is JSON Form useful?", } }, "form": [ { "key": "firstName", "type

我以前在我的项目中使用,但现在我迁移到react,所以我使用这个库()。 在jsonform中,我可以在表单部分中有一些不在模式中的字段集。像这样:

{
  "schema":
    {
      "firstName": {
      "type": "string",
      "title": "Is JSON Form useful?",
      }
    },
  "form": [
     {
      "key": "firstName",
      "type": "text",
     }, 
     {
      "title" : "this is non-schema",
      "type": "fieldset"
     }
   ]
}
你可以在测试。 请帮助我在中执行类似上述代码的操作。 我怎么能有一些不在模式中但想在uiSchema中显示的字段

react jsonschema表单也有一个。您可以找到名为“日期”的字段。它在uiSchema中添加,但在schema部分中不存在。结果中也没有显示此字段的任何内容。我不知道为什么他们用它,如果它不能在那里


谢谢。

日期只是uiSchema的一个例子,而游乐场这次不使用它。在这里,我创建了一个例子来帮助理解

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"
    }
  }
}
尤西切马

{
  "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"
    }
  }
}
JSONSchema中有四个属性:firstName、age、phone、date。UISchema中有四个属性:firstName、age、phone、date。它们是相同的。JSONSchema中的每个属性在UISchema中都有一个或更少的属性。JSONSchema中的类型类似字符串,在字符串中有一些子选项,如“updown”。我们在ui:ui:widget(UISchema)中设置它。这是我的结果。底部元素是您提到的日期。

这里有点混乱。UI模式基本上是一个对象文字,提供关于表单应该如何呈现的信息,而JSON模式告诉我们应该如何呈现。因此,如果它不在sechema中,就不能在uiSchma中显示。谢谢您的评论。我知道,但在我为您放置链接的jsonform中,您可以拥有一个没有任何模式字段的字段集。请在操场上做这件事,以便更好地理解我。我会回答你。希望能帮助你。非常感谢。所以你的意思是我不能有任何字段,即使只是在uiScheama有一个“字段集”。对总之,我可以说jsonform()具有此功能,但react jsonschema form()没有:(是的,你不能在uiScheama中有任何字段,即使是“字段集”。但是你只能在模式中有一个字段。@Zahrasafarthanks很多。我希望我可以自定义它,使其像我以前在项目中使用的那样工作:)@Root