我有一个基本的应用程序,可以从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发送此信息。但现在我发现react只是一个前端框架,所以我不确定是否可以在那里接收请求,或者是否只能发出请求,这将是我所考虑的体系结构中的一个重大变化
发布于 2020-06-21 07:56:21
您可以使用React向Python服务器发送GET请求,以使用任何客户端获取方法获取所需的数据,并根据这些数据呈现结果。这需要Python服务器托管要使用的端点。
https://stackoverflow.com/questions/62492894
复制相似问题