You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
通过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