Commit 4cce8eea authored by 前端-许佳敏's avatar 前端-许佳敏

新增同步字段的effect

parent 5bb4f29b
import { FormEffectHooks } from '@formily/antd'
import { useLinkageUtils } from '@/utils/formEffectUtils'
const { onFieldValueChange$ } = FormEffectHooks
/**
* @description 用于同步表单的值
* @param target 同步的目标路径
* @param syncArr 被同步的表单字段
*/
export const useSyncValues = (target: string, syncArr: string[]) => {
const linkage = useLinkageUtils()
onFieldValueChange$(target).subscribe(state => {
syncArr.forEach(v => {
linkage.value(v, state.value)
})
})
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment