【发布时间】:2019-06-11 17:47:03
【问题描述】:
我的帖子成功了,但是除了console.log()之外我不能在then语句中做任何事情;它总是跳到抓住。
axios.post('/group/15/discussion/'+ this.discussion.id+ '/schedule',this.form, {handleErrors:true})
.then(function(response) {
//this.form.valid = true;
console.log("success");
console.log('set form valid');
this.$refs['schedule-group-discussion-'+this.id].hide();
console.log('close modal');
/*this.$emit('updateDiscussion',response.data.discussion);
this.$toast.success(response.data.message,'Success!',{icon: 'fas fa-check-circle'});*/
})
.catch((error) => {
console.log("catch");
this.form.valid = false;
});
这是我的控制台日志,按顺序排列: 成功 设置表格有效 赶上
怎么了?
【问题讨论】:
-
你的 POST 响应状态码 200?
-
是的,它确实有代码 200
-
根据控制台日志输出,可以假设 this.$refs['schedule-group-discussion-'+this.id].hide();产生错误。您是否尝试过检查/记录捕获的错误?
-
@DavidHorák 是的,你是对的。它说“这个”是未定义的/
-
@JasonSpick 给你,这个问题与 axios 无关,而是与未定义的引用有关,应该很容易解决。