fn
useFieldArray
v0.0.16testeddemoManage a dynamic array field within a {@link useForm}. Exposes a reactive `fields` list with **stable keys** (preserved across reorders, so `v-for :key` keeps DOM/state intact) plus immutable `push`/`prepend`/`insert`/ `remove`/`move`/`swap`/`replace`/`update` operations that also re-key the matching errors and touched state.
Example
ts
const form = useForm({ initialValues: { users: [{ name: '' }] } });
const { fields, push, remove } = useFieldArray('users');
// <div v-for="(field, i) in fields" :key="field.key">
// <input v-model="field.value.name"> <buttonDemo
Loading demo…
Signature
ts
export function useFieldArray<T = any>(
path: MaybeRefOrGetter<string>,
options: UseFieldArrayOptions ={ ... }Type Parameters
T= anyParameters
| Parameter | Type | Description |
|---|---|---|
path | MaybeRefOrGetter<string> | The dotted path of the array field |
options? | UseFieldArrayOptions<any> | Optionally an explicit `form` |
Returns
UseFieldArrayReturn<T>The reactive entries and mutation helpers