function retRGObj(objName, xTime) {
return new Promise(
function (resolve, reject) {
let data = {}
findR(objName, xTime).then(function (msg) {
data.R = msg
console.log(data) //--> saves the expected value
}).then(findG(objName, xTime).then(function (msg) {
data.G = msg
console.log(data) //--> saves the expected value
}))
console.log(data) //--> all values are gone, returned value is "Object {}"
resolve(data)
})
}
我不知道我怎么不能返回最终值,它在最后一个范围内被清空。如何/为什么?