Closed hellowolrds closed 12 months ago
一样的啊 setSchemaByPath
我是在form_render内部自定义的组件,不是调用的库,没有暴露这个setSchemaByPath方法 const FrTable = ({ value, onChange, schema, style, ...rest }) => {
const [dataSource, setDataSource] = useState(schema.dataList||[]) const [columns, setColumns] = useState([])
useEffect(() => { console.log(dataSource) }, [dataSource])
const handleChange = (val, index, key) => { // const newData = [...dataSource]; // if (!newData[index]) { // newData[index] = {} // } // dataSource[index][key] = val; // setDataSource(dataSource); onChange("123")
setDataSource(prevDataSource => {
const newDataSource = [...prevDataSource]; // 创建一个新数组,以确保不直接修改原始状态
newDataSource[index][key] = val; // 更新指定位置的值
return newDataSource; // 返回新的数据源
});
// console.log(val, index, key, dataSource)
}
schema.dataList是我想在组件内部更新的,而不是直接调用form.setSchemaByPath这个方法
期望的新功能 (describe the expected new feature)
简述一下使用场景,便于开发者更好理解新功能的必要性 (describe your scenario for us to understand the need)
有些功能属性不好在表单设计器里配置,我想在组件里配置好,去更新全局的schema,然后导出schema的属性包含我更新的东西。 目前没有找到好的方法。dataList这属性就是我想在自定义组件里更新的属性,请大佬指教一下 { "type": "object", "labelWidth": 320, "displayType": "row", "formRule": {}, "column": 1, "properties": { "frtable_PP7g60": { "title": "", "type": "frtable", "dataList": [], "tableList": [ { "value": "1", "type": "1", "column_name": "字段1" } ], "properties": {}, "labelWidth": 220 } } }