【发布时间】:2018-10-24 19:17:05
【问题描述】:
编辑:也许我把我的例子简化得太多了。让我再试一次
file1.js
import conditonFunction from './conditonFunction'
console.log(conditonFunction())
file2.js
import asyncFunction from './asyncFunction'
export const conditonFunction = () => {
if (condition) {
return 'this doesnt matter'
} else {
asyncFunction().then(res => {
return res[0].whatever
})
}
}
如果我的条件不满足,我希望conditonFunction 的记录值是res 内asyncFunction 的值
我错过了什么?
【问题讨论】:
-
你真的给
asyncFunction()打了两次电话吗?还请修复语法错误 -then(调用缺少右括号。
标签: javascript ecmascript-6 promise es6-promise