您的位置:首页 > 产品设计 > UI/UE

vue请求接口第一次成功,第二次失败

2017-09-17 01:23 603 查看
使用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)
}
}
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: