Vue中axios获取的值可以通过Promise再次引用
let that = this
new Promise(function (resolve, reject) {
that.axios.post('/file/imgUpload', fd,
{
headers: {
'Content-Type': 'multipart/form-data'
}
}).then((response) => {
that.imgId = response.data.data
resolve(that.imgId);
}).catch((error) =>{
this.$message.error('头像上传失败,请重新上传!');
})
}).then(function (id){
that.axios.get('/file/view/'+id)
.then((response) => {
console.log(response)
})
})