我有一个axios封装的方法:
this.$http.post(Urls.register(), this.formItem).then(function (response) {
}.bind(this))
.catch(function (response) {
// 这里我想改变 this.$data.loading=false 怎么做?
console.log(response)
})
我在.catch()
方法中想要改变一个组件的值怎么改变?这里好像不能使用this.loading
,这里的this
是undefined
。
使用箭头函数,更改this指向Vue,或者你继续在catch后面bind(this),但是es6的箭头函数已经很普及了