Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
通过useState设置form-generator schema的时候,中间的可视区并没有绘制对应的表单。代码如下:
`import React, { memo, useEffect, useRef, useState } from 'react';
import DripFormGenerator from '@jdfed/form-generator';
import '@jdfed/form-generator/dist/index.css';
const Edit = memo(() => {
const generatorRef = useRef();
const [schema, setSchema] = useState({});
useEffect(() => {
const schemaJson = {
type: 'object',
validateTime: 'change',
ui: {
containerStyle: {
width: '33%',
padding: '0 10px 0 0',
},
},
theme: 'antd',
schema: [
{
type: 'array',
title: '多选框',
ui: {
type: 'checkbox',
theme: 'antd',
},
fieldKey: 'checkbox_ZkO_mT',
},
{
type: ['string', 'number', 'array'],
title: '选择器',
ui: {
type: 'select',
theme: 'antd',
style: {
width: 120,
},
options: [],
},
fieldKey: 'select_M0AZMz',
},
{
type: 'string',
title: '输入框',
ui: {
type: 'text',
style: {
width: '100%',
},
theme: 'antd',
},
fieldKey: 'text_HYrE2k',
},
{
type: 'array',
title: '级联选择',
ui: {
type: 'cascader',
theme: 'antd',
},
fieldKey: 'cascader_j2ndy2',
},
{
type: 'string',
title: '时间选择框',
ui: {
type: 'timePicker',
theme: 'antd',
},
fieldKey: 'timePicker_y9cE6R',
},
{
type: 'number',
title: '滑动输入条',
ui: {
type: 'slider',
theme: 'antd',
},
fieldKey: 'slider_a-imkw',
},
],
};
generatorRef.current = schemaJson;
const newSchema = { ...generatorRef.current };
setSchema(newSchema);
});
return (
{console.log('schema->', schema)}
);
});
Edit.displayName = 'GeneratorApp';
export default Edit;
`
Beta Was this translation helpful? Give feedback.
All reactions