wx.uploadFile返回数据面板数据正常,取值时undefined?
this.getUploadToken().then(value => {
return new Promise((resolve, reject) => {
wx.uploadFile({
url: value.path,
filePath: this.data.photo,
name: 'file',
formData: {
token: value.token
},
success: res => {
// console.log('uploaded')
if (res.data.code === 0) {
console.log(res.data.msg)
resolve(res.data.msg)
}else {
reject(res.data.err)
}
}
})
})
}).then(....
以上代码中,success: res => {} 里边 res.data.code === 0 无法执行,去掉 if 语句后发现,打印 res.data.msg 时是 undefined,但是开发工具的network面板里,upload接口返回的res.data里就是 code: 0 和 msg 字段,请问是什么原因?谢谢!