使用vue去請求接口發現問題來了:
我請求隻能請求一次,然後在按按鈕去請求的時候發現
502(這個是接口定義的)502就是傳了空的值過來 這個是其中一種情況,還有别的情況 你看了 大可試試我這樣的辦法
然後發現我前端代碼沒有問題,接口代碼也沒有問題
data() {
return {
form: {
old_password: '',
new_password: '',
confirm_password: ''
}
}
},
this.$http.post('/api/users/modifyPassword', this.form,
(res) => {
this.form = {
old_password: this.form.old_password,
new_password: this.form.new_password,
confirm_password: this.form.confirm_password
}
if (is.object(res)) {
console.log(res)
if (res.code === '0') {
this.$router.push({ path: '/my/' })
this.$toast.show(res.msg)
} else {
this.$toast.show(res.msg)
}
}
})