全局变量在then内赋值后在函数外调用内容为空?
var dm
db.collection(‘zhongdui’).where({
_openid: this.data.openid
}).get().then(res => {dm=res.data[0],console.log(dm)}) //打印结果为{duiming: {…}}
console.log(dm) //打印结果为undefined
var dm
db.collection(‘zhongdui’).where({
_openid: this.data.openid
}).get().then(res => {dm=res.data[0],console.log(dm)}) //打印结果为{duiming: {…}}
console.log(dm) //打印结果为undefined