vue的入门问题

clipboard.png
我想问下 axios 请求数据 给变量赋值 不用我这种方法,then 里面怎么可以直接给 this.seller 赋值 有其他方法可以让里面的tihs 与外面的this指向一致吗?

阅读 1.9k
3 个回答

使用箭头函数

.then((res)=>{
    if(res.status === 200 && res.data.errno === 0){
        this.seller = res.data.data
    }
})

嗯,感谢 大神

.then(function(response){
    ...
}.bind(this)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题