Page({
data: {
list: []
},
onLoad() {
wx.cloud.database().collection('xuesheng')
.get()
.then(res => {
console.log('数据请求成功', res)
this.setData({
list: res.data
})
})
.catch(res => {
console.log('数据请求失败', res)
})
},
addty() {
let num = this.data.list
console.log('此处可以请求到数据', num)//这个地方请求到了数据
wx.cloud.database().collection('zhanshi')
.add({
data: {
num: this.data.list//此处反应的数据为空
}
})**
.then(res => {
console.log('提交成功', res)
wx.showToast({
title: '提交成功',
})
})
.catch(res => {
console.log('提交失败', res)
})
},
你上面拿到的数据是你get返回来的数据,后面提交成功这里,你打印的是res,本来就是两个东西啊
云函数的这个add的api,只是保存,然后返回操作结果顶多给你个id。
你要自己再去查一遍数据才行。