Closed quintn closed 2 years ago
提供一个可以复现的最小的代码例子
提供一个可以复现的最小的代码例子
import FormRender, { useForm } from 'form-render';
const schema = { type: 'object', properties: { "select_GsXSaG": { "title": "城市", "type": "string", "enum": [], "enumNames": [], "widget": "select" }, "multiSelect_QD_nty": { "title": "标签", "description": "标签", "type": "array", "items": { "type": "string" }, "enum": [], "enumNames": [], "widget": "multiSelect" } }, }; const delay = ms => new Promise(res => setTimeout(res, ms)); const Demo = () => { const form = useForm(); const onMount = () => { form.setValues({ input1: 'hello world' });
delay(500).then(_ => {
form.setSchemaByPath('select_GsXSaG', {
enum: ['beijing', 'xiamen', 'shanghai'],
enumNames: ['北京', '厦门', '上海'],
});
form.setSchemaByPath('multiSelect_QD_nty', {
enum: ['a', 'b', 'c'],
enumNames: ['A', 'B', 'C'],
});
});
};
return <FormRender form={form} schema={schema} onMount={onMount} />;
};
export default Demo;
如上图 城市选了厦门之后,那个下拉框的选项就没了,同时标签的选项也没了。
我也遇到这个情况,循环form.setSchemaByPath后表单下拉都有选项,只要选了其中一个就全部没了
我目前解决办法就是退回1.7.3,今天升级的1.8.4-beta.3 退回了
这个问题修掉了嘛
同问
今天也遇到了,新建的项目照搬一模一样的代码,还是有问题,选中就会重新渲染,enum等参数就会被重置。 `import React, { useEffect } from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render';
const delay = ms => new Promise(res => setTimeout(res, ms));
const schema = { type: 'object', properties: { input1: { title: '简单输入框', type: 'string', required: true, }, select1: { title: '选择框', description: '加载中...', type: 'string', enum: [], widget: 'radio', }, }, };
const Demo = () => { const form = useForm();
const onMount = () => { form.setValues({ input1: 'hello world' });
delay(3000).then(_ => {
form.setSchemaByPath('select1', {
description: '',
enum: ['a', 'b', 'c'],
enumNames: ['早', '中', '晚'],
});
});
};
return
export default Demo;`
1.9.0 版本已经修复
form.setSchemaByPath('multiSelect_kXFfsG1', { "enum": ["a", "b", "c"], "enumNames": ["A", "B", "C"], });