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);
})
})
}
微信小程序开发问题解答
微信小程序开发者回答:
https://developers.weixin.qq.com/community/develop/doc/00082e3f538f704848a717f9d5c804
本文网址:http://www.91bianli.com/weixinxiaochengxu/34302.html