【发布时间】:2019-06-07 20:55:45
【问题描述】:
我想在 axios 之后执行 function2。我没有捕获错误。但仍然没有执行 Function2。
我想要但不起作用的代码:
add: function () {
axios.post('/add', this.person)
.then(response => {
if (response.data.etat) {
this.person = {};
this.function2();
}
})
.catch(error => {
console.log('errors: ', error)
})},
这是可行的,但我只想在 axios 通过时执行 function2。
add: function () {
axios.post('/add', this.person)
.then(response => {
if (response.data.etat) {
this.person = {};
}
})
.catch(error => {
console.log('errors: ', error)
})
this.function2();
},
有什么帮助吗?谢谢 !
【问题讨论】:
-
response.data.etat返回什么? -
什么都没有.. 但是我的 axios 通过并且我的数据被发送到数据库
标签: javascript vue.js vuejs2 axios vue-component