function getAllDatas() {
var finalResult = {
"isOk": 0,
"isNo": 0,
"isAll": 0
}
this.getUserDatas(0, function (result) {
console.log("ret");
console.log(result)
finalResult.isAll += result.isAll
finalResult.isNo += result.isNo
finalResult.isOk += result.isOk
});
console.log("最终数据:")
console.log(finalResult)
return finalResult
}
function getAllDatas() { return new Promise((resolve, reject) => { var finalResult = { "isOk": 0, "isNo": 0, "isAll": 0 } this.getUserDatas(0, function (result) { finalResult.isAll += result.isAll finalResult.isNo += result.isNo finalResult.isOk += result.isOk resolve(finalResult) }); }) } getAllDatas().then(res => { console.log('最终数据') console.log(res) })
function async test() {
let res = await getAllDatas()
console.log(res)
}