【发布时间】:2020-06-20 23:35:06
【问题描述】:
我有这个基本的应用程序,它可以从 Json 文件中生成表单:
import React, { Component } from "react";
import { render } from "react-dom";
import Form from "react-jsonschema-form";
const schema = {
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"required": [
"firstName",
"lastName"
],
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": ""
},
"telephone": {
"type": "string",
"title": "Telephone",
"minLength": 10
}
}
}
const log = type => console.log.bind(console, type);
render(
<Form
schema={schema}
autocomplete="on"
onChange={log("changed")}
onSubmit={log("submitted")}
onError={log("errors")}
/>,
document.getElementById("root")
);
现在,我需要的是能够通过更改 Json 文件/内容来随意更改表单:
const schema = {
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"required": [
"firstName",
"lastName"
],
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": ""
},
"telephone": {
"type": "string",
"title": "Telephone",
"minLength": 10
}
}
}
我从 Python 上的另一个应用程序获得了该信息,我当时的想法是发出 Post 请求以响应发送此信息。但是现在我看到 react 只是一个前端框架,所以我不确定是否可以在那里接收请求或者是否只能发出请求,这将是我正在考虑的架构的一个重大变化
【问题讨论】:
标签: javascript python reactjs