有人能解释一下为什么这个打印顺序是相反的吗?
代码:when('test')
.then(function() {console.log('should be first');})
.then(console.log('should be second'));
输出:should be second
should be first
PS:我正在使用when.js版本:when@3.4.3
您立即执行第二个console.log
,并将返回值传递给then
。您需要将函数传递给then
。
你已经有效地完成了:
var x = console.log('should be second')
when('test')
.then(function () { console.log('should be first'); })
.then(x);