WetFormDependencys 数据联动
基本介绍
Form 中的数据联动非常常见,所以我们封装了一个组件来进行数据处理。
引入方法: `import { WetProForm } from '@wetspace/pro-components
WetFormDependencys
只需要配置 relyprops
WetFormDependencys
会自动处理并且从表单中提取相应的值。
relyprops
参数必须要是一个数组,如果是嵌套的结构可以这样配置relyprops={['name', ['name2', 'text']]}
。配置的 relyprops
的值会在 slot的scope作用域中传入。relyprops={['name', ['name2', 'text']]}
传入的 relyValues
的值 为 [any,any],假设依赖数据为obj,数组第一个成员代指的是依赖数据obj.name
的值,数组的第二个成员是依赖数据obj.name2.text
的值
值得注意的是,如果依赖项只有一个数据源,那么relyValues
将直接是这个数据源的值
基本使用
属性
通用属性请参考WetProForm
的配置
属性 | 描述 | 类型 | 默许值 |
---|---|---|---|
relyprops | 数据依赖项配置 | string[] | (string | string[])[] | - |
dependencyChange | 依赖数据发生变化 | DependencyChangeType | - |
插槽
名称 | 说明 | 类型 |
---|---|---|
default | 默认渲染区域 | {relyprops:any|any[],setValue:(prop: string | string[], v: any) => void,getValue: (prop?: string | string[]) => void,parames:any} |
类型参考
ts
type DependencyChangeType = (p:{
relyValues: any|any[],
setValue: (p: string | string[], v: any) => void,
getValue: (prop?: string | string[]) => void,
}) =>(Partial<WetSchemaItemType> | void)