方法一:
JS插入代码
/*** 生命周期函数--监听页面加载*/
onLoad: function (options) {
const db = wx.cloud.database();
const collection1 = db.collection('table1'); //需要查询的数据表01
const collection2 = db.collection('table2'); //需要查询的数据表02
Promise.all([
collection1.get(),
collection2.get()
]).then(res => {
console.log('结果1:', res[0].data);
console.log('结果2:', res[1].data);
}).catch(err => {
console.error(err);
})
},
方法二:
Page({
/*** 生命周期函数--监听页面加载*/
onLoad: function (options) {
const db = wx.cloud.database();
const table1 = db.collection('table1').get();
const table2 = db.collection('table2').get();
Promise.all([table1, table2]).then(res => {
const result1 = res[0].data;
const result2 = res[1].data;
// 处理和显示查询结果
console.log(result1,result2);
})
}
)}