export const newitem= ({commit}, payload) => {
axios.post('/api/product/add', payload)
.then((response) => {
commit('additem', response.data);
})
}
methods: {
submit(){this.$store.dispatch('prod/newitem, this.$data.form);}
}
<div id="app">
<ul>
<li v-for="(item,i) in arr">{{item.name}} <button @click="someEvent(i)">delete</button></li>
</ul>
</div>
new Vue({
el: '#app',
data: {
arr: [
{
name: 'afaw',
loading: false
},
{
name: 'argeae',
loading: false
},
{
name: 'agsesf',
loading: false
}
]
},
methods: {
someEvent(index) {
this.arr[index].loading = true
}
}
});