美文网首页
axios then 里面不能用 this ,改变 data 失

axios then 里面不能用 this ,改变 data 失

作者: 雪妮爸爸 | 来源:发表于2019-03-27 00:27 被阅读0次
axios.get('https://www.apiopen.top/satinCommentApi?id=27610708', { 
params: { 
} 
}).then(function(data) { 
Vue.set(app, 'messages', data.data.data.normal.list) 
}).catch(function (error) { 
console.log(error); 
}); 

或者用 箭头函数

axios.get('https://www.apiopen.top/satinCommentApi?id=27610708', { 
params: { 
page: this.page 
} 
}).then((data) => { 
this.messages = data.data.data.normal.list; 
}).catch(function (error) { 
console.log(error); 
}); 

相关文章

网友评论

      本文标题:axios then 里面不能用 this ,改变 data 失

      本文链接:https://www.haomeiwen.com/subject/iuaovqtx.html