鍍金池/ 問答/HTML/ vue的入門問題

vue的入門問題

clipboard.png
我想問下 axios 請(qǐng)求數(shù)據(jù) 給變量賦值 不用我這種方法,then 里面怎么可以直接給 this.seller 賦值 有其他方法可以讓里面的tihs 與外面的this指向一致嗎?

回答
編輯回答
臭榴蓮
2017年3月5日 17:28
編輯回答
局外人

使用箭頭函數(shù)

.then((res)=>{
    if(res.status === 200 && res.data.errno === 0){
        this.seller = res.data.data
    }
})
2017年6月20日 10:00
編輯回答
半心人

嗯,感謝 大神

2017年2月6日 00:07
編輯回答
心上人
.then(function(response){
    ...
}.bind(this)
2017年8月30日 23:12