0
A basic example:
fellow () {
var self = this;
axios.post(`/@${this.follower}/follow/`)
.then(function (response) {
self.isfollowing = true;
})
.catch(function (error) {
console.log( error.response.data);
});
},
0
Axios has a series of methods you can execute after the response arrives. In the case of a post call your structure can be something like this
axios.post(YOUR ROUTE)
.then(function (response) {
//executes after getting a successful response
// here you can change your 'isfollowing' variable accordingly
})
.catch(function (error) {
//executes after getting an error response
});
-1
Fast way:
<template>
<div v-if="isnot">
<a href="#" @click.prevent="fellowUnfellow" v-if="isfollowing" >{{isfollowing ? "unFellow" : "Fellow"}}</a>
</div>
</template>
fellowUnfellow () {
axios.post(`/@${this.follower}/follow/`).then(function (r) {
this.isfollowing = !this.isfollowing;
})
}
- [Vuejs]-How to dynamically add questions to Vue Webpack template's meta.js file?
- [Vuejs]-Can't create new vue components
Source:stackexchange.com