为什么在.then()链接到Promise时未定义值?
特定
function doStuff(n /* `n` is expected to be a positive number */) { return new Promise(function(resolve, reject) { setTimeout(function() { resolve(n * 10) }, Math.floor(Math.random() * 1000)) }) .then(function(result) { if (result > 100) { console.log(result + " is greater than 100") } else { console.log(result + " is not greater than 100"); } })}doStuff(9).then(function(data) { console.log(data) // `undefined`, why?})
为什么要被拴data
undefined
在一起打电话?.then()
doStuff()
白衣染霜花
慕尼黑8549860
相关分类