In my Vue JS application, I have a feature that allows users to add items to an array.
After adding an item, I want to give users the ability to move the item up or down the array list.
I attempted to achieve this functionality with the following Vue method:
changePos: function(item, type = 1) {
this.items.move(this.items, item, type);
},
However, when calling this method in my template, I encountered an error:
this.items.move is not a function
This is how I called the method in my template:
<tbody>
<tr v-for="(item, key) in items">
<td>
<button class="btn btn-sm btn-rounded" @click="changePos(item,1)">UP</button>
<button class="btn btn-sm btn-rounded" @click="changePos(item,-1)">DOWN</button>
</td>
<td>@{{ item.code }}</td>
</tr>
</tbody>