class demo {
promiseFn() {
return new Promise((resolve, reject) => {
resolve(10);
});
}
FnA() {
return this.promiseFn()
.then(a => {
throw a;
})
.catch(e => {
console.log(e);
});
}
FnB() {
this.FnA().then(a => {
console.log(a, 11111111111);
});
}
}
new demo().FnB();
//10
//undefined 11111111111
为什么FnB的then回执行?
你的代码执行等价于下面的方式
因为catch 捕获执行后返回的也是一个promise,假如你在catch里 return e的话,最后就会输出