Hello. I’m using the f7-list with the v-for vue directive to create a list from an array of objects. The list is sortable and uses swipeout for deletions. Everything updates beautifully on the UI, but when I delete or reorder list items on the UI it’s out of sync with the underlying array of objects in the data section of vue. Additionally, if I add an element to the start of the array it does not get the ordering right on the UI, indicating that the f7 representation of the list is out of sync with the vue data. How do I solve this issue? Example below:
<f7-list sortable id="notes">
<f7-list-item v-for="item in items"
swipeout
:title="item.title"
:key="item.id">
<f7-swipeout-actions right>
<f7-swipeout-button delete>Delete</f7-swipeout-button>
</f7-swipeout-actions>
</f7-list-item>
</f7-list>
...
data() {
var items = [
{ id: 1, title: "my item 1" },
{ id: 2, title: "my item 2" },
{ id: 3, title: "my item 3" },
{ id: 4, title: "my item 4" }
];
return {
items: items // How do I make this array sync with what's on the UI? e.g. when order is changed or item is deleted.
}
},
method: {
addItem: function() {
this.items.unshift({ id: 5, title: "add this item to top" }); // if order has already been changed in UI, it may not add to the top
}
...