请问大佬们怎么让BBB函数接受到AAA函数return返回数据
javascript吧
全部回复
仅看楼主
level 1
破序
楼主
这样返回的是空
2022年10月09日 16点10分
1
level 1
破序
楼主
这是微信小程序云开发
2022年10月09日 16点10分
2
level 8
那个浪子
你可以这样写成回调函数
2022年10月10日 00点10分
3
破序
感谢大佬解惑
成功了
2022年10月10日 04点10分
破序
这是把B的执行函数贴到了A异步执行吧,如何还是由B处理A的return数据呢
2022年10月10日 04点10分
那个浪子
另请高明吧
2022年10月10日 06点10分
破序
不行呀,打印的是undefined
2022年10月10日 07点10分
level 13
iKurum
async吧
A = () => DB...then()
B = async () => {
const data = await A()
log(data)
}
2022年10月10日 07点10分
4
破序
不行呀,打印的是underfined
2022年10月10日 07点10分
level 1
破序
楼主
2022年10月10日 07点10分
5
iKurum
@破序
你的Aa函数,需要吧整个db返回(return DB.... 这样)
2022年10月10日 07点10分
破序
@iKurum
这样可以返回数据耶,谢谢大佬
2022年10月10日 07点10分
level 13
iKurum
工作条件有限,只能这么拍了。
不知道你那个db....函数是不是标准的Promise(没用过)
Promise的话,是会打印出data 123的
2022年10月10日 07点10分
6
level 1
就来亿小口
这不就是个简单的promise??
this.aaa().then(res=> console.log(res))
2022年10月19日 05点10分
7
破序
不行的,它说cannot read property "then" of undefined,不过用async await可以了
2022年10月20日 10点10分
1