mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
16 lines
391 B
TypeScript
16 lines
391 B
TypeScript
import { watch, inject } from 'vue';
|
|
import { FIELD_KEY } from '../field';
|
|
|
|
export function useLinkField(getValue: () => unknown) {
|
|
const field = inject(FIELD_KEY, null) as any;
|
|
|
|
if (field && !field.childFieldValue.value) {
|
|
field.childFieldValue.value = getValue;
|
|
|
|
watch(getValue, () => {
|
|
field.resetValidation();
|
|
field.validateWithTrigger('onChange');
|
|
});
|
|
}
|
|
}
|