被闭包整的蒙圈了,哪位帮改下啊!十条记录的数据库,查询后结果传不出来!
var db_total=0
db.collection('wy_gcb').where({}).count().then(res => {
db_total = res.total
console.log('总数1: ', db_total)
})
console.log('总数2: ', db_total)
输出结果是:
总数2: 0
总数1: 10
怎么改下,让输出结果是
总数1: 10
总数2: 10
框架类型 | 问题类型 | 终端类型 | AppID | 基础库版本 |
---|---|---|---|---|
小程序 | 需求 | 客户端 | wx58496b2a660ad8c5 | 2.4.0 |
被闭包整的蒙圈了,哪位帮改下啊!十条记录的数据库,查询后结果传不出来!
var db_total=0
db.collection('wy_gcb').where({}).count().then(res => {
db_total = res.total
console.log('总数1: ', db_total)
})
console.log('总数2: ', db_total)
输出结果是:
总数2: 0
总数1: 10
怎么改下,让输出结果是
总数1: 10
总数2: 10
1 个回答
必须在回调函数里响应结果