链接.then
和下一个函数调用之间的区别是什么,例如:
funcThatReturnsPromise().then((a) => {
}).then(doSomething)
使用
var b;
funcThatReturnsPromise().then((a) => {
b = a;
});
doSomething(b);
编辑我试过了,它也是这样:
var p2; var p1 = new Promise(function(resolve, reject) {
resolve(p2 = 'test1');
});
p1.catch(function(e){console.log('b',e)});
console.log('c',p2);
// result: c test1
VS
var p1 = new Promise(function(resolve, reject) {
resolve('test2');
});
p1.then(console.log).catch(function(e){console.log('b',e)});
// result: test2