[英]how can i use react form builder 2 in react js project
I have been trying to use react form builder 2 for my project but i cannot understand how to require it and then display form through it can anyone help please iam new at react js and in the past i have been just importing the library after installing but in this case i dont have the tags to import iam finding it difficult to use it.?我一直在尝试为我的项目使用react form builder 2,但我不明白如何要求它,然后通过它显示表单任何人都可以帮助我是react js的新手,过去我只是在安装后导入库但是在这种情况下,我没有要导入的标签,我发现很难使用它。?
basic usage
var React = require('react');
var FormBuilder = require('react-form-builder2');
React.render(
<FormBuilder.ReactFormBuilder />,
document.body
)
Props
var items = [{
key: 'Header',
name: 'Header Text',
icon: 'fa fa-header',
static: true,
content: 'Placeholder Text...'
},
{
key: 'Paragraph',
name: 'Paragraph',
static: true,
icon: 'fa fa-paragraph',
content: 'Placeholder Text...'
}];
<FormBuilder.ReactFormBuilder
url='path/to/GET/initial.json'
toolbarItems={items}
saveUrl='path/to/POST/built/form.json' />
React Form Generator
Now that a form is built and saved, let's generate it from the saved json.
var React = require('react');
var FormBuilder = require('react-form-builder2');
React.render(
<FormBuilder.ReactFormGenerator
form_action="/path/to/form/submit"
form_method="POST"
task_id={12} // Used to submit a hidden variable with the id to the form from the database.
answer_data={JSON_ANSWERS} // Answer data, only used if loading a pre-existing form with values.
authenticity_token={AUTH_TOKEN} // If using Rails and need an auth token to submit form.
data={JSON_QUESTION_DATA} // Question data
/>,
document.body
)
Try with https://github.com/rjsf-team/react-jsonschema-form you can choose the design of output.尝试使用https://github.com/rjsf-team/react-jsonschema-form可以选择 output 的设计。 and if you need a visual builder, you can use my project https://github.com/MedinaGitHub/react-jsonschema-form-builder
如果您需要可视化构建器,可以使用我的项目https://github.com/MedinaGitHub/react-jsonschema-form-builder
You should add bootstrap & font-awesome style sheets to index.html https://github.com/Kiho/react-form-builder/blob/master/public/index.html#L5您应该将引导程序和字体真棒样式表添加到 index.html https://github.com/Kiho/react-form-b uilder/blob/master/public/index.html#L5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.