Basic Usage
To use an array field, you can usefield.state.value on an array value in conjunction with v-for:
Adding Items to Arrays
Use thepushValue method to add items to your array:
Working with Sub-Fields
You can access and manipulate individual items in the array using bracket notation:Array Manipulation Methods
When working with array fields, you have access to several helper methods:- pushValue - Add a value to the end of the array
- removeValue - Remove a value at a specific index
- swapValues - Swap two values at different indices
- moveValue - Move a value from one index to another
- insertValue - Insert a value at a specific index
- replaceValue - Replace a value at a specific index
- clearValues - Clear all values in the array
Removing Items
Swapping Items
Complete Example
Here’s a full working example with array fields:Nested Object Arrays
You can work with arrays of complex objects with multiple properties:Validation with Array Fields
You can add validation to array fields and their sub-fields:Tips for Working with Arrays
Use proper keys
Always use a unique key for each item in your
v-for loop. While using the index is acceptable for simple cases, consider using a unique identifier if your items have one.