login() {
if(this.email.length > 0 && this.password.length >0) {
this.$http.post('/api/login', {
user: this.email,
password: this.password
})
.then(res => {
let userPwd = res.data
if(this.password == userPwd) {
this.$router.push("/")
} else {
alert("错误,请重新输入!")
}
})
.catch(err => {
console.log(err)
})
} else {
alert("输入错误!")
}
}
this.$router.push("/")不是跳到首頁,而是變成這樣:http://127.0.0.1:8080/login?email=yejia@qq.com&password=123456
,請問哪裡錯啦?
你這裡的 this指向已經不是 vue 的對象啦,可以這麼改
有沒有可能是已經跳轉了,但是主頁判斷成了沒有登錄,然後又跳回來了。