new Promise((resolve, reject) => {
debugger;//1
wx.cloud.callFunction({
name: ‘GetAllDataByTab’,//云函数
data: {
tab: ‘Theme’,
field: ‘Sort’,
mode: ‘asc’
},
success: res => {
debugger;//2
this.setData({
all_Theme: res.result.data
})
}
})
})
debugger;//3
代码的执行顺序为啥是1=》3=》2,如果要顺序是 1=》2=》3 应该怎样写
云函数这边能同步执行
// 云函数入口文件
const cloud = require(‘wx-server-sdk’)
cloud.init();
exports.main = (event, context) => {
const db = cloud.database();
return new Promise((resolve, reject) => {
db.collection(event.tab).orderBy(event.field, event.mode).get().then((res) => {
resolve(res);
})
})
}