这种写在app,js里的函数为什么读出来的bottle是undefined 不用async就又可以读出来
async publish(bottle) {
// 处理发布逻辑,上传数据至服务器
console.log(bottle)
var images = bottle.images
var data = await this.uploadImages(images)
var bottle = {
id:bottle.id,
content:bottle.content,
creator:wx.getStorageSync('userInfo').id,
images:JSON.stringify(data)
}
console.log(bottle)
wx.request({
url: this.globalData.url + '/bottles',
method: 'POST',
data: bottle,
success: (res) => {
if (res.data) {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
});
} else {
wx.showToast({
title: '保存失败',
icon: 'none',
duration: 2000
});
}
},
fail: () => {
wx.showToast({
title: '请求失败',
icon: 'none',
duration: 2000
});
}
});
},
两个bottle
参数名称重复了得嘛
哪个console.log是空的?