Skip to content

Commit c4c014c

Browse files
authored
Added array 'move' helper function to the documentation (#3952)
1 parent 844faec commit c4c014c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/src/pages/api/use-field-array.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,18 @@ const { replace, fields } = useFieldArray('links');
202202
// replace the entire array with these items
203203
replace([{ url: 'https://google.com' }, { url: 'https://vuejs.org' }]);
204204
```
205+
206+
<CodeTitle level="4">
207+
208+
`move(oldIdx:number, newIdx: number)`
209+
210+
</CodeTitle>
211+
212+
Moves an array item to a different position within the array.
213+
214+
```js
215+
const { move, fields } = useFieldArray('links');
216+
217+
// move array item to a different position
218+
move(2, 1);
219+
```

docs/src/pages/guide/composition-api/nested-objects-and-arrays.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ The `<useFieldArray />` function provides the following properties and functions
235235
- `swap(idxA: number, idxB: number)`: Swaps two array elements by their indexes.
236236
- `replace(items: any[])`: Replaces the entire array values with the given items.
237237
- `update(idx: number, value: any)`: Updates an array item value at the specified index.
238+
- `move(oldIdx: number, newIdx: number)`: Moves an array item to a different position within the array.
238239

239240
[Read the API reference](/api/use-field-array) for more information.
240241

0 commit comments

Comments
 (0)