My code is like this :
<template>
<a href="javascript:" class="btn btn-block btn-success" @click="addFavoriteStore($event)">
<span class="fa fa-heart"></span>
</a>
</template>
<script>
export default{
props:['idStore'],
mounted(){
this.checkFavoriteStore()
},
methods:{
addFavoriteStore(event){
event.target.disabled = true
const payload= {id_store: this.idStore}
// if the labal = unfavorite
if(unfavorite)
this.$store.dispatch('addFavoriteStore', payload)
// if the label = favorite
else
this.$store.dispatch('deleteFavoriteStore', payload)
setTimeout(function () {
location.reload(true)
}, 1500);
},
checkFavoriteStore(){
const payload= {id_store: this.idStore}
this.$store.dispatch('checkFavoriteStore', payload)
// get response
}
},
data: {
store_id: ''
}
}
</script>
I make the conditions as described above
You can look at the method addFavoriteStore
Whether that step is correct?
And how to determine it was favorite label or not to create conditions?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire