【发布时间】:2019-03-28 17:38:58
【问题描述】:
除非我在 axios 调用中使用逗号,否则编译错误。
这是错误。 '意外的令牌,应为“,”'
在 vue 中我有一个 axios 调用。
axios
.get('/api/messages/'+this.issue)
.then(response => (
this.messages = response.data;
console.log(response.data);
))
.catch(error => console.log(error));
如果我不使用逗号,我会收到编译错误。
axios
.get('/api/messages/'+this.issue)
.then(response => (
this.messages = response.data,
console.log(response.data)
))
.catch(error => console.log(error));
如果我尝试在 .then() 中运行 if() 语句,也会出现编译错误。我正在使用最新版本的 Laravel、Vue 和 Axios。其他人有这个问题吗?或者有什么解决办法?
【问题讨论】:
-
那是因为您在 then 回调中使用
()而不是{}