Code:
this.$axios.post("/auth", {
'username': this.username,
'password': this.password
}).then(function (res) {
this.$router.push('/');
}).catch(function (error) {
console.log(error);
});
modify:
this.$axios.post("/auth", {
'username': this.username,
'password': this.password
}).then(function (res) {
this.$router.push('/');
}.bind(this)).catch(function (error) {
console.log(error);
});
Behind the request axios plus .bind (this) can run a success